-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathsetup.py
80 lines (69 loc) · 2.98 KB
/
setup.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import os
import subprocess
import sys
import time
def make_setup():
if not sys.platform.startswith("win"):
print("This app only support Windows system!")
sys.exit()
else:
try:
import pkg_resources
except ImportError:
subprocess.call('python -m pip install setuptools', shell=True)
import pkg_resources
# Checking the required folders
folders = ["src"]
missing_folder = []
for i in folders:
if not os.path.exists(i):
missing_folder.append(i)
if missing_folder:
print("These folder(s) not available: " + str(missing_folder))
print("Download them from the repository properly")
sys.exit()
else:
print("All folders available!")
# Checking required modules
required = {"Pillow==10.1.0", "customtkinter==5.2.1", "packaging==23.2", "openai-whisper==20231117",
"pynvml==11.5.0", "pydub==0.25.1"}
installed = {pkg.key for pkg in pkg_resources.working_set}
missing = required - installed
missing_set = [*missing, ]
pytorch_win = "torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118"
pytorch_linux = "torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118"
pytorch_mac = "torch torchvision torchaudio"
# Download the modules if not installed
if missing:
try:
print("Installing modules...")
for x in range(len(missing_set)):
y = missing_set[x]
subprocess.call('python -m pip install ' + y, shell=True)
except Exception as e:
print(f"Error: {e}")
print("Unable to download! \nThis are the required ones: " + str(
required) + "\nUse 'pip install module_name' to download the modules one by one.")
time.sleep(3)
sys.exit()
try:
print("Installing Pytorch...")
if sys.platform.startswith("win"):
subprocess.call('python -m pip install ' + pytorch_win, shell=True)
elif sys.platform.startswith("linux"):
subprocess.call('python3 -m pip install ' + pytorch_linux, shell=True)
elif sys.platform.startswith("darwin"):
subprocess.call('python3 -m pip install ' + pytorch_mac, shell=True)
except Exception as e:
print(f"Error: {e}")
print("Unable to download! \nThis are the required ones: " + str(
required) + "\nUse 'pip/pip3 install module_name' to download the modules one by one.")
sys.exit()
else:
print("All required modules installed!")
# Everything done!
print("Setup Complete!")
time.sleep(5)
sys.exit()
if __name__ == "__main__":
make_setup()