-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.py
54 lines (51 loc) · 2.02 KB
/
run.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
45
46
47
48
49
50
51
52
53
54
import pkg_resources, sys, subprocess
def check_reqs():
missing = []
try:
with open("requirements.txt", "r") as requirements_file:
for line in requirements_file:
try:
pkg_resources.require(line)
except pkg_resources.DistributionNotFound as e:
missing.append(e.req.key)
except FileNotFoundError:
print("No requirements file found; can not verify if requirements are available.")
print("To skip this check and run anyway, run file with the argument \"-y\".")
return False
if len(missing) > 0:
print("Some dependencies were not found.")
try:
pkg_resources.require("pip")
except pkg_resources.DistributionNotFound:
print("Pip was not found on this system, and these dependencies must be manually installled.")
print("They are listed in requirements.txt in this directory.\n")
print("The unfound dependencies are:")
for miss in missing:
print(" ", miss)
return False
print("Pip was detected on this system.")
print("Would you like to automatically install all missing dependencies?")
result = input().strip().lower()[0]
if result == "y":
subprocess.call([sys.executable, "-m", "pip", "install", *missing])
else:
print("Pip was not used to install the dependencies.")
print("These dependencies can be found in requirements.txt.")
print("Please install the below dependencies manually.\n")
print("The unfound dependencies are:")
for miss in missing:
print(" ", miss)
return False
return True
def main(args):
skip_req_check = False
for arg in args:
if arg.strip() == "-y":
skip_req_check = True
if not skip_req_check:
if not check_reqs():
return False
import gui
gui.main()
if __name__ == "__main__":
main(sys.argv[1:])