-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.py
More file actions
95 lines (84 loc) · 2.45 KB
/
Copy pathbuild.py
File metadata and controls
95 lines (84 loc) · 2.45 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
"""
V-Link - Build Script
Builds Windows executable via PyInstaller.
"""
import os
import subprocess
import sys
from pathlib import Path
def build():
root = Path(__file__).resolve().parent
dist_dir = root / "dist"
try:
import PyInstaller # noqa: F401
except ImportError:
print("Installing PyInstaller...")
subprocess.run([sys.executable, "-m", "pip", "install", "pyinstaller"], check=True)
# Ensure QR dependencies are present for mobile connect dialog.
try:
import qrcode # noqa: F401
from PIL import Image # noqa: F401
except ImportError:
print("Installing QR dependencies (qrcode[pil])...")
subprocess.run([sys.executable, "-m", "pip", "install", "qrcode[pil]"], check=True)
# Keep runtime executable path stable for in-place updates and shortcuts.
output_name = "V-Link"
cmd = [
sys.executable,
"-m",
"PyInstaller",
"--noconfirm",
"--clean",
"--onefile",
"--windowed",
"--name",
output_name,
"--icon",
"app_icon.ico",
"--version-file",
"version.txt",
"--paths",
"src",
"--add-data",
"app_icon.ico;.",
"--add-data",
"src/ui/web_interface.html;ui",
"--add-data",
"resources/logo.png;resources",
"--add-data",
"resources/locales/ru.json;resources/locales",
"--add-data",
"resources/locales/en.json;resources/locales",
"--hidden-import",
"qrcode",
"--hidden-import",
"qrcode.image.pil",
"--hidden-import",
"PIL.Image",
"--exclude-module",
"numpy",
"--exclude-module",
"PySide6",
"--exclude-module",
"PySide2",
"--exclude-module",
"PyQt5",
"src/main.py",
]
print("Build command:")
print(" ".join(map(str, cmd)))
subprocess.run(cmd, check=True)
exe_path = dist_dir / f"{output_name}.exe"
if exe_path.exists():
for stale in dist_dir.glob("V-Link-*.exe"):
try:
stale.unlink()
except Exception:
pass
print(f"\nBuild complete: {exe_path}")
print(f"Size: {exe_path.stat().st_size // 1024} KB")
else:
raise FileNotFoundError(f"Expected output not found: {exe_path}")
if __name__ == "__main__":
os.chdir(os.path.dirname(os.path.abspath(__file__)))
build()