-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
executable file
·41 lines (35 loc) · 1008 Bytes
/
setup.py
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
#!/usr/bin/env python3
import PyInstaller.__main__
import os
import shutil
import subprocess
import sys
def install():
#Create binary
try:
PyInstaller.__main__.run([
'--onefile',
'discovery.py'
])
except:
raise
exit()
#install to /usr/bin/local
dir = os.getcwd()
shutil.copy(dir+'/dist/discovery', '/usr/local/bin/discovery')
try:
shutil.rmtree(dir+'/__pycache__')
except:
print(dir+'/__pychache__ already deleted')
try:
shutil.rmtree(dir+'/build')
except:
print(dir+"/build already deleted")
print("Executable found in /usr/local/bin/ and "+dir+"/dist/")
subprocess.Popen("sudo cp discovery.1 /usr/local/man/man1/discovery.1", shell=True)
if __name__ == '__main__':
#Restart script with admin privileges if launched with normal privileges
if os.geteuid() == 0:
install()
else:
subprocess.check_call(['sudo', sys.executable] + sys.argv)