-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.py
45 lines (33 loc) · 1.06 KB
/
install.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
42
43
44
import os
import sys
import getopt
def usage():
print("\nUsage:")
print("install.py -v python_version | -h help\n")
print("-v \t Options: Any python version installed in the system.")
print("Specifies which python version the libraries should be installed to.\nPython version is by default set to the python path\n")
print("-h \t Help: Get information on how to run the file\n")
def arg_parse(argv):
"""
"""
python_version = ""
try:
opts, args = getopt.getopt(argv, "v:", ["python_version"])
except getopt.GetoptError:
usage()
sys.exit(2)
for opt, arg in opts:
if opt == "-h":
usage()
sys.exit()
if opt == "-v":
python_version = arg
return python_version
def main(python_version):
if not python_version:
os.system("pip install -r requirements.txt")
else:
os.system(python_version + " -m pip install -r requirements.txt")
if __name__ == "__main__":
python_version = arg_parse(sys.argv[1:])
main(python_version)