-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.py
46 lines (42 loc) · 1.4 KB
/
init.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
import sys
import subprocess
import pkg_resources
# Check if requirements are satisfied
dependencies = ['click==8.1.7', 'Pillow', 'opencv-python']
def main():
try:
pkg_resources.require(dependencies)
except:
requirements()
def requirements():
install_list = []
install_prompt = []
for item in dependencies:
try:
pkg_resources.require(item)
# If requirement is already installed append value 0
install_list.append([item, 0])
except:
# If requirement is NOT installed append value 1
install_list.append([item, 1])
install_prompt.append(item)
check = sum(x[1] for x in install_list)
if check > 0:
while True:
print('FUKITUP requires {prompt}'.format(prompt=install_prompt))
answer = input('Install? (Y/N): ')
answer = answer.upper()
if answer == 'Y':
for item in install_list:
if item[1] == 1:
requirement = item[0]
print('Installing', requirement, '(This may take awhile...)')
subprocess.check_call([sys.executable, '-m', 'pip', 'install', requirement])
break
if answer == 'N':
print('Operation canceled')
exit()
else:
pass
if __name__ == "__main__":
main()