-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
54 lines (45 loc) · 1.54 KB
/
setup.py
File metadata and controls
54 lines (45 loc) · 1.54 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
from platform import system
from shutil import which
import os, sys, subprocess, params
operating_sys = system()
termux = False
def install_reqs(is_termux):
if is_termux:
subprocess.run('pkg update && pkg upgrade', shell=True)
subprocess.run(['pkg', 'install', 'termux-api'])
try:
subprocess.run(['pip', 'install', '-r', 'requirements.txt'])
except:
if operating_sys != 'Linux':
print("Could not install required python packages.")
sys.exit(1)
else:
with open('requirements.txt', 'r') as f:
print('')
for line in f:
print(line.strip())
print("\nYou probably have to install these python libraries")
print("according to your distribution package manager.")
print("If you have already installed these packages, continue.")
cont = input("Continue? [Y/n] ")
if cont.lower() == 'n':
return
try:
match operating_sys:
case 'Windows':
script = 'setup_win.bat'
case 'Darwin' | 'Linux' | 'Android':
if 'TERMUX_VERSION' in os.environ:
script = 'bash setup_linux.sh -t'
termux = True
else:
script = 'bash setup_linux.sh'
case _ :
print("Ooops, your os is unsupported!")
sys.exit(1)
install_reqs(termux)
subprocess.run(script, shell=True)
except KeyboardInterrupt:
sys.exit(1)
except Exception as e:
raise e