Skip to content

Commit 76cb126

Browse files
authored
v2.6.2 - easy windows install
1 parent f19ea0e commit 76cb126

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed

src/setup.py

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import sys
2+
import subprocess
3+
import os
4+
import ctypes
5+
6+
def user_confirmation(message):
7+
return ctypes.windll.user32.MessageBoxW(0, message, "Confirmation", 1) == 1
8+
9+
def check_python_version_and_confirm():
10+
major, minor = map(int, sys.version.split()[0].split('.')[:2])
11+
if major < 3 or (major == 3 and minor < 10):
12+
ctypes.windll.user32.MessageBoxW(0, "Python 3.10 or higher is required for this installation.", "Python Version Error", 0)
13+
return False
14+
else:
15+
return user_confirmation(f"Python version {sys.version.split()[0]} detected. Click OK to proceed with the installation, or Cancel to stop.")
16+
17+
def check_cuda_version():
18+
try:
19+
cuda_version_output = subprocess.check_output(["nvcc", "--version"]).decode('utf-8')
20+
if "release" in cuda_version_output:
21+
cuda_version = cuda_version_output.split("release ")[1].split(",")[0]
22+
return cuda_version
23+
else:
24+
return None
25+
except FileNotFoundError:
26+
return None
27+
28+
def display_cuda_message():
29+
cuda_version = check_cuda_version()
30+
if cuda_version is None:
31+
proceed_without_cuda = ctypes.windll.user32.MessageBoxW(0, "No CUDA installation detected. Would you like to proceed with a CPU-only installation?", "CUDA Check", 1) == 1
32+
return proceed_without_cuda
33+
elif cuda_version == "11.8":
34+
return ctypes.windll.user32.MessageBoxW(0, "You have the correct CUDA version (11.8). Click OK to proceed.", "CUDA Check", 1) == 1
35+
else:
36+
update_cuda = ctypes.windll.user32.MessageBoxW(0, f"Incorrect version of CUDA installed (Version: {cuda_version}). Would you like to proceed with a CPU-only installation?", "CUDA Check", 1) == 1
37+
return update_cuda
38+
39+
def manual_installation_confirmation():
40+
if not user_confirmation("Have you installed Git? Click OK to confirm, or Cancel to exit installation."):
41+
return False
42+
if not user_confirmation("Have you installed Git Large File Storage? Click OK to confirm, or Cancel to exit installation."):
43+
return False
44+
if not user_confirmation("Have you installed Pandoc? Click OK to confirm, or Cancel to exit installation."):
45+
return False
46+
return True
47+
48+
def setup_windows_installation():
49+
if not check_python_version_and_confirm():
50+
return
51+
if not manual_installation_confirmation():
52+
return
53+
cuda_installed = display_cuda_message()
54+
os.system("python -m pip install --upgrade pip")
55+
if cuda_installed:
56+
if user_confirmation("Click OK for Nvidia GPU-acceleration support or Cancel for CPU only."):
57+
os.system("pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118")
58+
else:
59+
os.system("pip install torch torchvision torchaudio")
60+
else:
61+
os.system("pip install torch torchvision torchaudio")
62+
os.system("pip install -r requirements.txt")
63+
print("Installation completed successfully.")
64+
print("Run 'Python gui.py' to start program.")
65+
66+
setup_windows_installation()

0 commit comments

Comments
 (0)