forked from fossasia/pslab-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
58 lines (44 loc) · 1.7 KB
/
setup.py
File metadata and controls
58 lines (44 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env python
from __future__ import print_function
import os
import shutil
from distutils.util import execute
from subprocess import call
from setuptools import setup, find_packages
from setuptools.command.install import install
def udev_reload_rules():
call(["udevadm", "control", "--reload-rules"])
def udev_trigger():
call(["udevadm", "trigger", "--subsystem-match=usb", "--attr-match=idVendor=04d8", "--action=add"])
def install_udev_rules(raise_exception):
if check_root():
shutil.copy('99-pslab.rules', '/etc/udev/rules.d')
execute(udev_reload_rules, [], "Reloading udev rules")
execute(udev_trigger, [], "Triggering udev rules")
else:
msg = "You must have root privileges to install udev rules. Run 'sudo python setup.py install'"
if raise_exception:
raise OSError(msg)
else:
print(msg)
def check_root():
return os.geteuid() == 0
class CustomInstall(install):
def run(self):
if not hasattr(self, "root"):
install_udev_rules(True)
elif self.root is not None:
if 'debian' not in self.root:
install_udev_rules(True)
install.run(self)
setup(name='PSL',
version='1.1.0',
description='Pocket Science Lab by FOSSASIA',
author='FOSSASIA PSLab Developers',
author_email='pslab-fossasia@googlegroups.com',
url='https://pslab.io/',
install_requires=['numpy>=1.16.3.', 'pyqtgraph>=0.9.10'],
packages=find_packages(),
package_data={'': ['*.css', '*.png', '*.gif', '*.html', '*.css', '*.js', '*.png', '*.jpg', '*.jpeg', '*.htm',
'99-pslab.rules']},
cmdclass={'install': CustomInstall})