-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.py
More file actions
74 lines (59 loc) · 1.82 KB
/
build.py
File metadata and controls
74 lines (59 loc) · 1.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
"""
Build script for creating standalone executable
Run this script to create SequentialPaste.exe
"""
import PyInstaller.__main__
import os
import shutil
# Configuration
APP_NAME = "SequentialPaste"
MAIN_SCRIPT = "main.py"
ICON_PATH = "assets/icon.ico" # Will use default if not exists
def build():
"""Build the executable"""
print("Building Sequential Paste executable...")
# Base PyInstaller arguments
args = [
MAIN_SCRIPT,
'--name', APP_NAME,
'--onefile', # Single executable
'--windowed', # No console window
'--clean', # Clean build
'--noconfirm', # Overwrite without asking
]
# Add icon if exists
if os.path.exists(ICON_PATH):
args.extend(['--icon', ICON_PATH])
# Hidden imports that PyInstaller might miss
hidden_imports = [
'pystray._win32',
'PIL._tkinter_finder',
'plyer.platforms.win.notification',
]
for imp in hidden_imports:
args.extend(['--hidden-import', imp])
# Add data files if assets folder exists
if os.path.exists('assets'):
args.extend(['--add-data', 'assets;assets'])
# Run PyInstaller
PyInstaller.__main__.run(args)
print("\n" + "="*50)
print(f"BUILD COMPLETE!")
print(f"Executable: dist/{APP_NAME}.exe")
print("="*50)
def clean():
"""Clean build artifacts"""
dirs_to_remove = ['build', '__pycache__', f'{APP_NAME}.spec']
for d in dirs_to_remove:
if os.path.exists(d):
if os.path.isdir(d):
shutil.rmtree(d)
else:
os.remove(d)
print(f"Removed: {d}")
if __name__ == "__main__":
import sys
if len(sys.argv) > 1 and sys.argv[1] == 'clean':
clean()
else:
build()