-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.py
More file actions
64 lines (51 loc) · 1.91 KB
/
build.py
File metadata and controls
64 lines (51 loc) · 1.91 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
import PyInstaller.__main__
import customtkinter
import os
import shutil
import sys
# clean previous build artifacts
if os.path.exists('build'):
shutil.rmtree('build')
if os.path.exists('dist'):
shutil.rmtree('dist')
# Get customtkinter path to add data files
ctk_path = os.path.dirname(customtkinter.__file__)
# Define the separator for add-data (semicolon for Windows)
sep = ';'
# Exclude heavy libraries not needed for a PDF Reader
excludes = [
'tensorflow', 'torch', 'keras', 'transformers', 'huggingface_hub',
'scipy', 'pandas', 'matplotlib', 'sklearn', 'numpy',
'IPython', 'jupyter', 'notebook'
]
# Arguments for PyInstaller
args = [
'main.py', # Main script
'--name=LexoraPDFReader', # Name of the executable
'--noconsole', # Windowed mode (no console)
'--onefile', # Single executable
f'--add-data={ctk_path}{sep}customtkinter', # Add CustomTkinter data
'--clean', # Clean cache
'--windowed',
]
# Add exclusions
for pkg in excludes:
args.append(f'--exclude-module={pkg}')
print("Building Lexora PDF Reader (Optimized)...")
PyInstaller.__main__.run(args)
# Create Release Folder
release_dir = os.path.join(os.getcwd(), 'Release', 'LexoraPDFReader_v1.0.0')
if os.path.exists(release_dir):
shutil.rmtree(release_dir)
os.makedirs(release_dir)
# Copy artifacts
exe_src = os.path.join('dist', 'Lexora PDF Reader.exe')
exe_dst = os.path.join(release_dir, 'Lexora PDF Reader.exe')
changelog_src = 'changelog.md'
changelog_dst = os.path.join(release_dir, 'changelog.md')
if os.path.exists(exe_src):
shutil.copy2(exe_src, exe_dst)
print(f"Copied executable to {exe_dst}")
print(f"Build complete! The results are available in:")
print(f" - Dist: {os.path.abspath('dist')}")
print(f" - Release: {release_dir}")