Skip to content

Commit 092ee6b

Browse files
authored
Add files via upload
1 parent a436f9e commit 092ee6b

File tree

1 file changed

+121
-0
lines changed

1 file changed

+121
-0
lines changed

setup_cpu_only.py

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
import subprocess
2+
import sys
3+
import os
4+
import time
5+
from pathlib import Path
6+
7+
def install_libraries_with_retry(max_retries=3, delay=3):
8+
libraries = [
9+
"certifi==2024.7.4",
10+
"charset-normalizer==3.3.2",
11+
"colorama==0.4.6",
12+
"ctranslate2==4.3.1",
13+
"filelock==3.15.4",
14+
"fsspec==2024.5.0",
15+
"huggingface-hub==0.24.1",
16+
"idna==3.7",
17+
"jinja2==3.1.4",
18+
"llvmlite==0.43.0",
19+
"markdown-it-py==3.0.0",
20+
"MarkupSafe==2.1.5",
21+
"mdurl==0.1.2",
22+
"more-itertools==10.3.0",
23+
"mpmath==1.3.0",
24+
"networkx==3.3",
25+
"numba==0.60.0",
26+
"numpy==1.26.4",
27+
"openai-whisper==20231117",
28+
"packaging==24.1",
29+
"platformdirs==4.2.2",
30+
"psutil==6.0.0",
31+
"pygments==2.18.0",
32+
"pyyaml==6.0.1",
33+
"regex==2024.5.15",
34+
"requests==2.32.3",
35+
"rich==13.7.1",
36+
"safetensors==0.4.3",
37+
"sympy==1.12.1",
38+
"tiktoken==0.7.0",
39+
"https://download.pytorch.org/whl/cpu/torch-2.2.2%2Bcpu-cp311-cp311-win_amd64.whl#sha256=88e63c916e3275fa30a220ee736423a95573b96072ded85e5c0171fd8f37a755",
40+
"tokenizers==0.19.1",
41+
"tqdm==4.66.4",
42+
"typing-extensions==4.12.2",
43+
"typing_extensions==4.12.2",
44+
"urllib3==2.2.2",
45+
'git+https://github.com/shashikg/WhisperS2T.git@e7f7e6dbfdc7f3a39454feb9dd262fd3653add8c#egg=whisper_s2t'
46+
]
47+
48+
failed_installations = []
49+
multiple_attempts = []
50+
51+
for library in libraries:
52+
for attempt in range(max_retries):
53+
try:
54+
print(f"\nAttempt {attempt + 1} of {max_retries}: Installing {library}")
55+
command = [sys.executable, "-m", "uv", "pip", "install", library, "--no-deps", "--no-cache-dir"]
56+
subprocess.run(command, check=True, capture_output=True, text=True)
57+
print(f"Successfully installed {library}")
58+
if attempt > 0:
59+
multiple_attempts.append((library, attempt + 1))
60+
break
61+
except subprocess.CalledProcessError as e:
62+
print(f"Attempt {attempt + 1} failed. Error: {e.stderr.strip()}")
63+
if attempt < max_retries - 1:
64+
print(f"Retrying in {delay} seconds...")
65+
time.sleep(delay)
66+
else:
67+
print(f"Failed to install {library} after {max_retries} attempts.")
68+
failed_installations.append(library)
69+
70+
print("\n--- Installation Summary ---")
71+
if failed_installations:
72+
print("\nThe following libraries failed to install:")
73+
for lib in failed_installations:
74+
print(f"- {lib}")
75+
76+
if multiple_attempts:
77+
print("\nThe following libraries required multiple attempts to install:")
78+
for lib, attempts in multiple_attempts:
79+
print(f"- {lib} (took {attempts} attempts)")
80+
81+
if not failed_installations and not multiple_attempts:
82+
print("\nAll libraries installed successfully on the first attempt.")
83+
elif not failed_installations:
84+
print("\nAll libraries were eventually installed successfully.")
85+
86+
return failed_installations, multiple_attempts
87+
88+
def main():
89+
start_time = time.time()
90+
91+
# install uv
92+
print("\033[92mInstalling uv:\033[0m")
93+
subprocess.run(["pip", "install", "uv"], check=True)
94+
95+
# install pyside6
96+
print("\033[92mInstalling PySide6:\033[0m")
97+
subprocess.run(["uv", "pip", "install", "pyside6", "--no-cache-dir", "--link-mode=copy"], check=True)
98+
99+
# Upgrade pip, setuptools, and wheel using uv
100+
print("\033[92mUpgrading pip, setuptools, and wheel:\033[0m")
101+
subprocess.run(f"{sys.executable} -m uv pip install --upgrade pip setuptools wheel", shell=True, check=True)
102+
103+
# install other libraries
104+
print("\033[92mInstalling dependencies:\033[0m")
105+
failed, multiple = install_libraries_with_retry()
106+
107+
if not failed:
108+
print("\033[92mInstallation was successful! The program is ready to use.")
109+
print(f"To run it, enter the command: python ct2_main.py\033[0m")
110+
else:
111+
print("\033[91mInstallation encountered some issues. Please review the installation summary above.\033[0m")
112+
113+
end_time = time.time()
114+
total_time = end_time - start_time
115+
hours, rem = divmod(total_time, 3600)
116+
minutes, seconds = divmod(rem, 60)
117+
118+
print(f"\033[92m\nTotal installation time: {int(hours):02d}:{int(minutes):02d}:{seconds:05.2f}\033[0m")
119+
120+
if __name__ == "__main__":
121+
main()

0 commit comments

Comments
 (0)