-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_windows.py
More file actions
102 lines (83 loc) · 2.82 KB
/
build_windows.py
File metadata and controls
102 lines (83 loc) · 2.82 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
96
97
98
99
100
101
102
"""
Build script for creating Windows executable using PyInstaller.
This script should be run on a Windows machine with Python and PyInstaller installed.
Usage:
python build_windows.py
"""
import os
import sys
import subprocess
from pathlib import Path
# Build configuration
APP_NAME = "PPTCommandExecutor"
MAIN_SCRIPT = "main.py"
ICON_FILE = "assets/favicon.ico"
# PyInstaller options
PYINSTALLER_ARGS = [
"pyinstaller",
"--name", APP_NAME,
"--onefile", # Single executable file
"--windowed", # No console window
"--icon", ICON_FILE,
"--add-data", "assets;assets", # Include assets folder (Windows syntax)
"--hidden-import", "flask",
"--hidden-import", "flask_cors",
"--hidden-import", "socketio",
"--hidden-import", "gevent",
"--hidden-import", "geventwebsocket",
"--hidden-import", "PIL",
"--hidden-import", "customtkinter",
"--hidden-import", "qrcode",
"--hidden-import", "pyautogui",
"--hidden-import", "engineio.async_drivers.gevent",
"--clean", # Clean PyInstaller cache
"--noconfirm", # Replace output directory without asking
MAIN_SCRIPT
]
def check_requirements():
"""Check if all requirements are met."""
print("Checking requirements...")
# Check if on Windows
if sys.platform != "win32":
print("ERROR: This script should be run on Windows")
return False
# Check if main.py exists
if not Path(MAIN_SCRIPT).exists():
print(f"ERROR: {MAIN_SCRIPT} not found")
return False
# Check if icon file exists
if not Path(ICON_FILE).exists():
print(f"WARNING: Icon file {ICON_FILE} not found")
# Check if assets folder exists
if not Path("assets").exists():
print("WARNING: assets folder not found")
# Check if PyInstaller is installed
try:
subprocess.run(["pyinstaller", "--version"], check=True, capture_output=True)
print("✓ PyInstaller is installed")
except (subprocess.CalledProcessError, FileNotFoundError):
print("ERROR: PyInstaller is not installed")
print("Install it with: pip install pyinstaller")
return False
return True
def build():
"""Build the Windows executable."""
print("\n" + "="*60)
print(f"Building {APP_NAME} for Windows...")
print("="*60 + "\n")
if not check_requirements():
sys.exit(1)
# Run PyInstaller
print("Running PyInstaller...\n")
try:
subprocess.run(PYINSTALLER_ARGS, check=True)
print("\n" + "="*60)
print("BUILD SUCCESSFUL!")
print("="*60)
print(f"\nExecutable location: dist/{APP_NAME}.exe")
print(f"You can distribute the entire 'dist' folder or just the .exe file")
except subprocess.CalledProcessError as e:
print(f"\nERROR: Build failed: {e}")
sys.exit(1)
if __name__ == "__main__":
build()