-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile.py
More file actions
112 lines (92 loc) · 3.42 KB
/
makefile.py
File metadata and controls
112 lines (92 loc) · 3.42 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
103
104
105
106
107
108
109
110
111
112
import os
import zipfile
import subprocess
import time
import sys
from src.common import __version__
def check_pyinstaller():
"""Check if PyInstaller is installed and install if missing."""
try:
subprocess.run(['pyinstaller', '--version'], capture_output=True, check=True)
print("✓ PyInstaller found")
return True
except (subprocess.CalledProcessError, FileNotFoundError):
print("⚠ PyInstaller not found, installing...")
try:
subprocess.run([sys.executable, '-m', 'pip', 'install', 'pyinstaller'], check=True)
print("✓ PyInstaller installed successfully")
return True
except subprocess.CalledProcessError as e:
print(f"✗ Failed to install PyInstaller: {e}")
return False
def build_exe():
"""Build the VsmartEditor executable using PyInstaller."""
print("Building VsmartEditor executable...")
if not check_pyinstaller():
raise RuntimeError("PyInstaller is not available")
pyinstaller_cmd = [
'pyinstaller',
'--name=VsmartEditor',
'--onefile',
# '--windowed',
'--noconfirm',
'--distpath=dist',
'--hidden-import=src.conf',
'--hidden-import=src.sub_window',
'--hidden-import=src.element_id',
'--hidden-import=src.nodes',
'--hidden-import=src.qss.nodeeditor_dark_resources',
'--hidden-import=nodeeditor',
'--hidden-import=nodeeditor.node_editor_widget',
'--hidden-import=nodeeditor.node_edge',
'--hidden-import=nodeeditor.node_graphics_view',
'--hidden-import=nodeeditor.node_node',
'--hidden-import=nodeeditor.utils',
'--icon=src/appicon.ico',
'--add-data=src/icons;src/icons',
'src/main.py'
]
subprocess.run(pyinstaller_cmd, check=True)
print("✓ Executable built successfully")
def archive_examples():
"""Archive the examples folder to dist directory."""
print("Archiving examples folder...")
examples_path = 'src/examples'
output_path = 'dist/examples.zip'
if not os.path.exists(examples_path):
print("⚠ Examples folder not found, skipping archive")
return
# Ensure dist directory exists
os.makedirs('dist', exist_ok=True)
with zipfile.ZipFile(output_path, 'w', zipfile.ZIP_DEFLATED) as archive:
for root, dirs, files in os.walk(examples_path):
for file in files:
file_path = os.path.join(root, file)
rel_path = os.path.relpath(file_path, examples_path)
archive.write(file_path, rel_path)
print(f"✓ Examples archived to {output_path}")
def main():
"""Main build process."""
start_time = time.time()
print(f"Building VsmartEditor v{__version__}")
print("=" * 40)
try:
# Kill any running instances
subprocess.run(['taskkill', '/F', '/IM', 'VsmartEditor.exe'],capture_output=True)
# Build executable
build_exe()
# Archive examples
archive_examples()
elapsed = time.time() - start_time
print("=" * 40)
print(f"✓ Build completed in {elapsed:.1f} seconds")
print("Output directory: dist/")
except subprocess.CalledProcessError as e:
print(f"✗ Build failed: {e}")
return 1
except Exception as e:
print(f"✗ Unexpected error: {e}")
return 1
return 0
if __name__ == "__main__":
exit(main())