-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathpyinstaller.spec
More file actions
135 lines (122 loc) · 3.75 KB
/
Copy pathpyinstaller.spec
File metadata and controls
135 lines (122 loc) · 3.75 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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# code: language=python
# main.spec
# This file tells PyInstaller how to bundle your application
from PyInstaller.building.api import EXE, PYZ
from PyInstaller.building.build_main import Analysis, COLLECT, BUNDLE
import sys
import os
import site
from pathlib import Path
version_file = Path(os.path.dirname(SPEC)) / "VERSION" # pyright: ignore[reportUndefinedVariable]. pyright complains about SPEC being undefined
app_version = version_file.read_text().strip().lstrip("v") if version_file.exists() else "dev"
site_packages_path = None
block_cipher = None
for site_path in site.getsitepackages():
if 'site-packages' in site_path:
site_packages_path = site_path
break
if site_packages_path is None:
raise RuntimeError("The site-packages directory could not be found. Please setup the python envrionment correctly and try again...")
a = Analysis(
['src/cibmangotree/__main__.py'], # Main entry point
pathex=['.', 'src'], # Ensure all paths are correctly included
binaries=[],
datas=[
# version file, if defined
*(
[('./VERSION', '.')]
if os.path.exists('VERSION') else []
),
# GUI icons (Simple Icons for footer links)
('src/cibmangotree/gui/icons', 'cibmangotree/gui/icons'),
# Vue GUI components
('src/cibmangotree/gui/components/dist', 'cibmangotree/gui/components/dist'),
# NiceGUI static files (required for GUI mode)
(os.path.join(site_packages_path, 'nicegui'), 'nicegui'),
],
hiddenimports=[
'numpy',
'asyncio',
'polars',
'linkify_it',
'markdown_it',
'mdurl',
'pythonjsonlogger',
'pythonjsonlogger.json',
# NiceGUI (required for GUI mode)
'nicegui',
'nicegui.elements',
'nicegui.events',
'nicegui.ui',
'fastapi',
], # Include any imports that PyInstaller might miss
excludes=[
'pytest',
'py',
'setuptools',
'pip',
'wheel',
],
runtime_hooks=[],
)
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
if sys.platform == "darwin":
# For onedir build: EXE only contains scripts
exe = EXE(
pyz,
a.scripts,
exclude_binaries=True, # This makes it onedir, not onefile
name='CIBMangoTree',
debug=False,
bootloader_ignore_signals=False,
strip=True,
upx=True,
console=False, # No console window for GUI app
entitlements_file="./mango.entitlements",
codesign_identity=os.getenv('APPLE_APP_CERT_ID'),
)
# Collect all files for the bundle (onedir structure)
coll = COLLECT(
exe,
a.binaries,
a.zipfiles,
a.datas,
strip=True,
upx=True,
name='CIBMangoTree'
)
# Create macOS app bundle from the collected files
app = BUNDLE(
coll,
name='CIBMangoTree.app',
icon='cibmt.icns',
bundle_identifier='org.civictechdc.cibmangotree',
info_plist={
'NSPrincipalClass': 'NSApplication',
'NSHighResolutionCapable': 'True',
'CFBundleShortVersionString': app_version,
'CFBundleName': 'CIB Mango Tree', # Display name (can have spaces)
},
)
else:
# Windows/Linux: onedir mode (avoids runtime temp extraction issues with antivirus)
exe = EXE(
pyz,
a.scripts,
exclude_binaries=True, # onedir structure
name='CIBMangoTree',
debug=True,
strip=False,
upx=True,
console=False, # No console window for GUI app
icon='cibmt.ico',
)
coll = COLLECT(
exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=True,
name='CIBMangoTree',
)