NeuroDonu commited on
Commit
403bdae
·
verified ·
1 Parent(s): 2aa24be

Update visomaster/visomaster_install.py

Browse files
Files changed (1) hide show
  1. visomaster/visomaster_install.py +108 -107
visomaster/visomaster_install.py CHANGED
@@ -1,108 +1,109 @@
1
- import os
2
- import subprocess
3
- import urllib.request
4
-
5
- aria2c_url = "https://huggingface.co/datasets/NeuroDonu/PortableSource/resolve/main/aria2c.exe"
6
- cuda_url = "https://huggingface.co/datasets/NeuroDonu/PortableSource/resolve/main/CUDA_124.7z"
7
- updater_url = "https://huggingface.co/datasets/NeuroDonu/PortableVersions/resolve/main/visomaster/updater.bat"
8
- start_url = "https://huggingface.co/datasets/NeuroDonu/PortableVersions/resolve/main/visomaster/start_nvidia.bat"
9
- git_repo_url = "https://github.com/visomaster/VisoMaster"
10
- models_url = "https://huggingface.co/datasets/NeuroDonu/PortableVersions/resolve/main/visomaster_models.7z"
11
- ffmpeg_url = "https://github.com/visomaster/visomaster-assets/releases/download/v0.1.0_dp/ffmpeg.exe"
12
-
13
- base_dir = os.path.dirname(os.path.abspath(__file__))
14
- visomaster_dir = os.path.join(base_dir, "Visomaster")
15
- aria2c_exe_path = os.path.join(base_dir, "aria2c.exe")
16
- cuda_archive_path = os.path.join(base_dir, "CUDA_124.7z")
17
- cuda_extract_dir = os.path.join(base_dir, "CUDA")
18
- seven_zip_path = os.path.join(base_dir, "7z.exe")
19
- git = os.path.join(base_dir, "git", "cmd", "git.exe")
20
- python = os.path.join(base_dir, "python", "python.exe")
21
- requirements = os.path.join(visomaster_dir, "requirements_cu124.txt")
22
- updater_bat = os.path.join(base_dir, "updater.bat")
23
- start_bat = os.path.join(base_dir, "start_nvidia.bat")
24
- ffmpeg_path = os.path.join(visomaster_dir, "dependencies", "ffmpeg.exe")
25
- pip_cmd = [python, "-m", "pip", "install", "uv"]
26
- uv_cmd = [python, "-m", "uv", "pip", "install", "-r"]
27
- models_path= os.path.join(visomaster_dir, "model_assets")
28
- models_name= os.path.join(models_path, "visomaster_models.7z")
29
-
30
- cuda_bin_path = os.path.join(base_dir, "CUDA", "bin")
31
- cuda_lib_path = os.path.join(base_dir, "CUDA", "lib")
32
-
33
-
34
- def download_with_urllib(url, destination):
35
- with urllib.request.urlopen(url) as response, open(destination, 'wb') as out_file:
36
- shutil.copyfileobj(response, out_file)
37
-
38
- def download_with_aria2c(url, destination,):
39
- subprocess.run(
40
- [
41
- aria2c_exe_path,
42
- "-d", os.path.dirname(destination),
43
- "-o", os.path.basename(destination),
44
- "-j", "16",
45
- "-x", "16",
46
- url
47
- ],check=True)
48
-
49
- def extract_archive(archive_path, extract_dir):
50
- subprocess.run([seven_zip_path, "x", archive_path], check=True)
51
-
52
- def clone_git_repo(repo_url, clone_dir):
53
- if os.path.exists(clone_dir):
54
- return
55
- try:
56
- subprocess.run([git, "clone", repo_url, clone_dir], check=True)
57
- except subprocess.CalledProcessError as e:
58
- exit(1)
59
-
60
- def modify_requirements_file(file_path):
61
- with open(file_path, 'r', encoding='utf-8') as file:
62
- content = file.read()
63
- modified_content = content.replace("--extra-index-url", "--index-url")
64
- with open(file_path, 'w', encoding='utf-8') as file:
65
- file.write(modified_content)
66
-
67
- def setup_cuda_paths():
68
- if os.path.exists(CUDA_BIN_PATH) and os.path.exists(CUDA_LIB_PATH):
69
- current_path = os.environ.get("PATH", "")
70
- os.environ["PATH"] = f"{CUDA_BIN_PATH};{CUDA_LIB_PATH};{current_path}"
71
-
72
- def install_requirements():
73
- subprocess.run([pip_cmd])
74
- subprocess.run([uv_cmd, requirements])
75
-
76
- def download_bat():
77
- download_with_urllib(updater_url, updater_bat)
78
- download_with_urllib(start_url, start_bat)
79
-
80
- def ffmpeg():
81
- download_with_urllib(ffmpeg_url, ffmpeg_path)
82
-
83
- def download_models():
84
- download_with_aria2c(models_url, models_name)
85
- extract_archive(models_name, models_path)
86
-
87
- if __name__ == "__main__":
88
- if not os.path.exists(aria2c_exe_path):
89
- download_with_urllib(aria2c_url, aria2c_exe_path)
90
- if not os.path.exists(cuda_archive_path):
91
- download_with_aria2c(cuda_url, cuda_archive_path, aria2c_exe_path)
92
- if not os.path.exists(cuda_extract_dir):
93
- extract_archive(cuda_archive_path, seven_zip_path)
94
- if os.path.exists(cuda_extract_dir):
95
- os.remove(cuda_archive_path)
96
-
97
- clone_git_repo(git_repo_url, visomaster_dir)
98
- setup_cuda_paths()
99
- modify_requirements_file(requirements)
100
- install_requirements()
101
- if not os.path.exists(start_bat):
102
- download_bat()
103
- if not os.path.exists(ffmpeg_path):
104
- ffmpeg()
105
- if not os.path.exists(models_path):
106
- download_models()
107
-
 
108
  print("Установка завершена!")
 
1
+ import os
2
+ import subprocess
3
+ import urllib.request
4
+ import shutil
5
+
6
+ aria2c_url = "https://huggingface.co/datasets/NeuroDonu/PortableSource/resolve/main/aria2c.exe"
7
+ cuda_url = "https://huggingface.co/datasets/NeuroDonu/PortableSource/resolve/main/CUDA_124.7z"
8
+ updater_url = "https://huggingface.co/datasets/NeuroDonu/PortableVersions/resolve/main/visomaster/updater.bat"
9
+ start_url = "https://huggingface.co/datasets/NeuroDonu/PortableVersions/resolve/main/visomaster/start_nvidia.bat"
10
+ git_repo_url = "https://github.com/visomaster/VisoMaster"
11
+ models_url = "https://huggingface.co/datasets/NeuroDonu/PortableVersions/resolve/main/visomaster_models.7z"
12
+ ffmpeg_url = "https://github.com/visomaster/visomaster-assets/releases/download/v0.1.0_dp/ffmpeg.exe"
13
+
14
+ base_dir = os.path.dirname(os.path.abspath(__file__))
15
+ visomaster_dir = os.path.join(base_dir, "Visomaster")
16
+ aria2c_exe_path = os.path.join(base_dir, "aria2c.exe")
17
+ cuda_archive_path = os.path.join(base_dir, "CUDA_124.7z")
18
+ cuda_extract_dir = os.path.join(base_dir, "CUDA")
19
+ seven_zip_path = os.path.join(base_dir, "7z.exe")
20
+ git = os.path.join(base_dir, "git", "cmd", "git.exe")
21
+ python = os.path.join(base_dir, "python", "python.exe")
22
+ requirements = os.path.join(visomaster_dir, "requirements_cu124.txt")
23
+ updater_bat = os.path.join(base_dir, "updater.bat")
24
+ start_bat = os.path.join(base_dir, "start_nvidia.bat")
25
+ ffmpeg_path = os.path.join(visomaster_dir, "dependencies", "ffmpeg.exe")
26
+ pip_cmd = [python, "-m", "pip", "install", "uv"]
27
+ uv_cmd = [python, "-m", "uv", "pip", "install", "-r"]
28
+ models_path= os.path.join(visomaster_dir, "model_assets")
29
+ models_name= os.path.join(models_path, "visomaster_models.7z")
30
+
31
+ cuda_bin_path = os.path.join(base_dir, "CUDA", "bin")
32
+ cuda_lib_path = os.path.join(base_dir, "CUDA", "lib")
33
+
34
+
35
+ def download_with_urllib(url, destination):
36
+ with urllib.request.urlopen(url) as response, open(destination, 'wb') as out_file:
37
+ shutil.copyfileobj(response, out_file)
38
+
39
+ def download_with_aria2c(url, destination,):
40
+ subprocess.run(
41
+ [
42
+ aria2c_exe_path,
43
+ "-d", os.path.dirname(destination),
44
+ "-o", os.path.basename(destination),
45
+ "-j", "16",
46
+ "-x", "16",
47
+ url
48
+ ],check=True)
49
+
50
+ def extract_archive(archive_path, extract_dir):
51
+ subprocess.run([seven_zip_path, "x", archive_path], check=True)
52
+
53
+ def clone_git_repo(repo_url, clone_dir):
54
+ if os.path.exists(clone_dir):
55
+ return
56
+ try:
57
+ subprocess.run([git, "clone", repo_url, clone_dir], check=True)
58
+ except subprocess.CalledProcessError as e:
59
+ exit(1)
60
+
61
+ def modify_requirements_file(file_path):
62
+ with open(file_path, 'r', encoding='utf-8') as file:
63
+ content = file.read()
64
+ modified_content = content.replace("--extra-index-url", "--index-url")
65
+ with open(file_path, 'w', encoding='utf-8') as file:
66
+ file.write(modified_content)
67
+
68
+ def setup_cuda_paths():
69
+ if os.path.exists(CUDA_BIN_PATH) and os.path.exists(CUDA_LIB_PATH):
70
+ current_path = os.environ.get("PATH", "")
71
+ os.environ["PATH"] = f"{CUDA_BIN_PATH};{CUDA_LIB_PATH};{current_path}"
72
+
73
+ def install_requirements():
74
+ subprocess.run([pip_cmd])
75
+ subprocess.run([uv_cmd, requirements])
76
+
77
+ def download_bat():
78
+ download_with_urllib(updater_url, updater_bat)
79
+ download_with_urllib(start_url, start_bat)
80
+
81
+ def ffmpeg():
82
+ download_with_urllib(ffmpeg_url, ffmpeg_path)
83
+
84
+ def download_models():
85
+ download_with_aria2c(models_url, models_name)
86
+ extract_archive(models_name, models_path)
87
+
88
+ if __name__ == "__main__":
89
+ if not os.path.exists(aria2c_exe_path):
90
+ download_with_urllib(aria2c_url, aria2c_exe_path)
91
+ if not os.path.exists(cuda_archive_path):
92
+ download_with_aria2c(cuda_url, cuda_archive_path, aria2c_exe_path)
93
+ if not os.path.exists(cuda_extract_dir):
94
+ extract_archive(cuda_archive_path, seven_zip_path)
95
+ if os.path.exists(cuda_extract_dir):
96
+ os.remove(cuda_archive_path)
97
+
98
+ clone_git_repo(git_repo_url, visomaster_dir)
99
+ setup_cuda_paths()
100
+ modify_requirements_file(requirements)
101
+ install_requirements()
102
+ if not os.path.exists(start_bat):
103
+ download_bat()
104
+ if not os.path.exists(ffmpeg_path):
105
+ ffmpeg()
106
+ if not os.path.exists(models_path):
107
+ download_models()
108
+
109
  print("Установка завершена!")