-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.py
More file actions
77 lines (60 loc) · 1.8 KB
/
Copy pathbuild.py
File metadata and controls
77 lines (60 loc) · 1.8 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
#!/usr/bin/env python3
"""
Build script — packages Teleprompter into a standalone executable.
Usage:
python build.py
Requirements:
pip install pyinstaller
Produces:
dist/teleprompter.exe (Windows)
dist/teleprompter (Linux)
"""
import subprocess
import sys
import os
import shutil
SCRIPT = "teleprompter.py"
APP_NAME = "teleprompter"
def ensure_pyinstaller():
"""Install PyInstaller if not present."""
try:
import PyInstaller # noqa: F401
print("[OK] PyInstaller is installed.")
except ImportError:
print("[*] PyInstaller not found — installing...")
subprocess.check_call([sys.executable, "-m", "pip", "install",
"pyinstaller", "--quiet"])
print("[OK] PyInstaller installed.")
def build():
os.chdir(os.path.dirname(os.path.abspath(__file__)))
ensure_pyinstaller()
# Clean previous builds
for d in ("build", "dist", f"{APP_NAME}.spec"):
if os.path.isdir(d):
shutil.rmtree(d)
elif os.path.isfile(d):
os.remove(d)
cmd = [
sys.executable, "-m", "PyInstaller",
"--onefile",
"--windowed",
"--name", APP_NAME,
"--clean",
SCRIPT,
]
print(f"[*] Building: {' '.join(cmd)}")
subprocess.check_call(cmd)
if sys.platform == "win32":
exe = os.path.join("dist", f"{APP_NAME}.exe")
else:
exe = os.path.join("dist", APP_NAME)
if os.path.isfile(exe):
size_mb = os.path.getsize(exe) / (1024 * 1024)
print(f"\n[OK] Build successful!")
print(f" Output: {os.path.abspath(exe)}")
print(f" Size: {size_mb:.1f} MB")
else:
print("\n[ERROR] Build failed — executable not found.")
sys.exit(1)
if __name__ == "__main__":
build()