-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.py
More file actions
66 lines (51 loc) · 1.72 KB
/
build.py
File metadata and controls
66 lines (51 loc) · 1.72 KB
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
"""Сборка кода в exe файл"""
import os
import shutil
import subprocess
import sys
def cleanup():
"""Очистка временных файлов"""
if os.path.exists("build"):
shutil.rmtree("build")
if os.path.exists("ScrapTF_Raffles.spec"):
os.remove("ScrapTF_Raffles.spec")
def run_cmd(args):
print("> " + " ".join(args))
subprocess.check_call(args)
def ensure_deps():
"""Ensure pip and install dependencies needed for the build."""
python = sys.executable
project_dir = os.path.dirname(os.path.abspath(__file__))
req_path = os.path.join(project_dir, "requirements.txt")
# Upgrade pip to avoid resolver edge cases on CI
run_cmd([python, "-m", "pip", "install", "--upgrade", "pip"])
if os.path.exists(req_path):
run_cmd([python, "-m", "pip", "install", "-r", req_path])
else:
# Minimal fallback set to build on CI even without requirements.txt
run_cmd([python, "-m", "pip", "install", "pyinstaller", "PyQt6"])
def build_exe():
"""Сборка .exe файла"""
if os.path.exists("dist"):
shutil.rmtree("dist")
if os.path.exists("build"):
shutil.rmtree("build")
desktop_app_path = os.path.join(os.path.dirname(
os.path.abspath(__file__)), "desktop_app.py")
pyinstaller_args = [
sys.executable, "-m", "PyInstaller",
"--noconfirm",
"--clean",
"--onefile",
"--windowed",
"--name", "ScrapTF_Raffles",
"--icon", "icon.ico",
"--hidden-import", "PyQt6.QtChart",
"--collect-all", "PyQt6",
desktop_app_path
]
run_cmd(pyinstaller_args)
if __name__ == "__main__":
ensure_deps()
build_exe()
cleanup()