-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.py
More file actions
84 lines (66 loc) · 2.21 KB
/
Copy pathbuild.py
File metadata and controls
84 lines (66 loc) · 2.21 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
#!/usr/bin/env python3
"""Build script - Use PyInstaller to create Windows executable"""
import os
import sys
import subprocess
import shutil
from pathlib import Path
def clean_build_dirs():
"""Clean previous build directories"""
dirs_to_clean = ['build', 'dist', '__pycache__']
for dir_name in dirs_to_clean:
dir_path = Path(dir_name)
if dir_path.exists():
print(f"Cleaning directory: {dir_path}")
shutil.rmtree(dir_path)
# Clean .spec file
spec_file = Path("PDFConcat.spec")
if spec_file.exists():
spec_file.unlink()
def build_executable():
"""Build using PyInstaller"""
print("\nStarting build process...")
# PyInstaller command parameters
cmd = [
sys.executable, "-m", "PyInstaller",
"--name", "PDFConcat",
"--onefile", # Package into single file
"--windowed", # Hide console window
"--icon=icons/pdf-blue.ico", # Blue icon for exe file
"--add-data", "src;src", # Include src directory
"--hidden-import", "tkinter",
"--hidden-import", "tkinter.ttk",
"--hidden-import", "tkinter.filedialog",
"--hidden-import", "tkinter.messagebox",
"--hidden-import", "PIL",
"--hidden-import", "fitz",
"--hidden-import", "numpy",
"src/gui.py" # Entry file
]
# If there is an icon file, uncomment and modify the path below
# cmd.extend(["--icon", "assets/icon.ico"])
# Run build command
result = subprocess.run(cmd)
if result.returncode == 0:
print("\n[Success] Build completed successfully!")
print(f"Executable file located at: {Path('dist/PDFConcat.exe').absolute()}")
else:
print("\n[Error] Build failed!")
sys.exit(1)
def main():
print("=" * 50)
print("PDFConcat - Build Script")
print("=" * 50)
# Check if in the correct directory
if not Path("src/gui.py").exists():
print("[Error] Please run this script from the project root directory")
sys.exit(1)
# Clean previous builds
clean_build_dirs()
# Build
build_executable()
print("\n" + "=" * 50)
print("Build complete!")
print("=" * 50)
if __name__ == "__main__":
main()