-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall.py
61 lines (48 loc) · 1.27 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# -*- coding: utf-8 -*-
import os
import threading as thread
import easygui as gui
BASE_PATH = 'dist'
is_rebuilt = False
is_uninstalled = False
is_installed = False
def getname():
if not os.path.exists(BASE_PATH):
print(f'{BASE_PATH} was not found')
os._exit(1)
files = [file for file in os.listdir(BASE_PATH) if file.endswith('.whl')]
if len(files) == 1:
return files[0]
print('wheel file was not unique')
os._exit(1)
def rebuild():
global is_rebuilt
os.system('del /s /q dist\*.*')
os.system('python setup.py bdist_wheel')
is_rebuilt = True
def uninstall():
global is_uninstalled
os.system('pip uninstall MEP -y')
is_uninstalled = True
def install():
global is_installed
while (not is_rebuilt) and (not is_uninstalled):
pass
path = f'{BASE_PATH}/' + getname()
os.system(f'pip install {path}')
is_installed = True
def create_threads():
return [
thread.Thread(target=rebuild),
thread.Thread(target=uninstall),
thread.Thread(target=install)
]
def main():
for t in create_threads():
t.start()
while True:
if is_installed:
gui.msgbox('Successfully install MEP')
os._exit(0)
if __name__ == '__main__':
main()