Repository navigation
Expand file tree
/
Copy pathbuild.py
More file actions
95 lines (80 loc) · 2.86 KB
/
Copy pathbuild.py
File metadata and controls
95 lines (80 loc) · 2.86 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
import os
import shutil
import subprocess
import sys
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
DIST_DIR = os.path.join(BASE_DIR, "dist")
BUILD_DIR = os.path.join(BASE_DIR, "build")
APPS = [
{
"name": "SimpleUpdater",
"entry": os.path.join(BASE_DIR, "standalone_updater.py"),
"description": "Simple Git Project Updater (Standalone)",
},
{
"name": "ManagedUpdater",
"entry": os.path.join(BASE_DIR, "managed_updater.py"),
"description": "Simple Git Project Updater (Managed)",
},
{
"name": "UpdateManager",
"entry": os.path.join(BASE_DIR, "update_manager.py"),
"description": "Update Manager Dashboard",
},
]
def build_all():
print("=" * 60)
print("Building Simple Updater Suite (.exe binaries)")
print("=" * 60)
os.makedirs(DIST_DIR, exist_ok=True)
for app in APPS:
name = app["name"]
entry = app["entry"]
print(f"\n---> Building {name}.exe from {entry}...")
icon_path = os.path.join(BASE_DIR, "assets", "icon.ico")
assets_dir = os.path.join(BASE_DIR, "assets")
cmd = [
sys.executable,
"-m",
"PyInstaller",
"--noconfirm",
"--clean",
"--onefile",
"--windowed",
"--name",
name,
f"--icon={icon_path}",
f"--add-data={assets_dir};assets",
f"--paths={BASE_DIR}",
entry,
]
result = subprocess.run(cmd, cwd=BASE_DIR)
if result.returncode != 0:
print(f"Error: Failed to build {name}.exe (exit code {result.returncode})")
sys.exit(result.returncode)
target_exe = os.path.join(DIST_DIR, f"{name}.exe")
if os.path.exists(target_exe):
size_mb = os.path.getsize(target_exe) / (1024 * 1024)
print(f"SUCCESS: Built {target_exe} ({size_mb:.2f} MB)")
else:
print(f"Warning: {target_exe} not found in dist directory.")
# Create zip package containing all 3 executables
print("\n---> Packaging executables into zip bundle...")
import zipfile
zip_name = "simple-updater-win.zip"
zip_path = os.path.join(DIST_DIR, zip_name)
with zipfile.ZipFile(zip_path, "w", zipfile.ZIP_DEFLATED) as zf:
for app in APPS:
exe_file = f"{app['name']}.exe"
exe_src = os.path.join(DIST_DIR, exe_file)
if os.path.exists(exe_src):
zf.write(exe_src, arcname=exe_file)
print(f" Added {exe_file} to {zip_name}")
zip_size_mb = os.path.getsize(zip_path) / (1024 * 1024)
print(f"SUCCESS: Created {zip_path} ({zip_size_mb:.2f} MB)")
print("\n" + "=" * 60)
print("Build finished successfully!")
print(f"Binaries available in: {DIST_DIR}")
print("=" * 60)
if __name__ == "__main__":
build_all()