-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathchimpstackr.spec
More file actions
212 lines (193 loc) · 5.94 KB
/
chimpstackr.spec
File metadata and controls
212 lines (193 loc) · 5.94 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
# -*- mode: python ; coding: utf-8 -*-
"""
PyInstaller spec file for ChimpStackr.
Produces two executables from shared libraries:
- chimpstackr (GUI, no console window)
- chimpstackr-cli (CLI, with console)
Build with:
pyinstaller chimpstackr.spec
Output goes to dist/chimpstackr/
"""
import sys
import os
import subprocess
from PyInstaller.utils.hooks import collect_all, collect_submodules
block_cipher = None
# ── Bake version from git tag at build time ──
try:
_ver = subprocess.check_output(
["git", "describe", "--tags", "--always"],
text=True, timeout=5,
).strip()
except Exception:
_ver = "dev"
# Write static version file so runtime doesn't need git
with open(os.path.join("src", "_version_static.py"), "w") as f:
f.write(f'__version__ = "{_ver}"\n')
# ── Collect problematic dependencies ──
# Numba/llvmlite need special handling — their native libs are often missed
numba_datas, numba_binaries, numba_hiddenimports = collect_all('numba')
pyfftw_datas, pyfftw_binaries, pyfftw_hiddenimports = collect_all('pyfftw')
rawpy_datas, rawpy_binaries, rawpy_hiddenimports = collect_all('rawpy')
imageio_datas, imageio_binaries, imageio_hiddenimports = collect_all('imageio')
scipy_datas, scipy_binaries, scipy_hiddenimports = collect_all('scipy')
# ── Data files ──
datas = [
('packaging/icons', 'packaging/icons'),
('packaging/chimpstackr.desktop', 'packaging'),
]
datas += numba_datas
datas += pyfftw_datas
datas += rawpy_datas
datas += imageio_datas
datas += scipy_datas
# ── Binary files ──
binaries = []
binaries += numba_binaries
binaries += pyfftw_binaries
binaries += rawpy_binaries
binaries += imageio_binaries
binaries += scipy_binaries
# ── Hidden imports ──
hiddenimports = [
'src', 'src.settings', 'src.config', 'src.cli', 'src.run',
'src.algorithms', 'src.algorithms.API', 'src.algorithms.dft_imreg',
'src.algorithms.stacking_algorithms', 'src.algorithms.stacking_algorithms.cpu',
'src.MainWindow', 'src.MainWindow.icons', 'src.MainWindow.style',
'src.ImageLoadingHandler',
'cv2', 'numpy', 'scipy', 'scipy.ndimage', 'scipy.ndimage.interpolation',
'imageio', 'imageio.v2',
]
hiddenimports += numba_hiddenimports
hiddenimports += pyfftw_hiddenimports
hiddenimports += rawpy_hiddenimports
hiddenimports += imageio_hiddenimports
hiddenimports += scipy_hiddenimports
# ── Excludes (reduce size) ──
excludes = [
'PyQt5', 'PyQt6', 'tkinter', 'matplotlib', 'IPython',
'notebook', 'jupyter', 'sphinx', 'docutils',
]
# ── Shared Analysis (both executables use the same collected files) ──
a = Analysis(
['src/run.py'],
pathex=['.'],
binaries=binaries,
datas=datas,
hiddenimports=hiddenimports,
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=excludes,
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False,
)
# Also analyze CLI entry point (merges into same analysis)
a_cli = Analysis(
['src/cli.py'],
pathex=['.'],
binaries=[],
datas=[],
hiddenimports=hiddenimports,
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=excludes,
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False,
)
# Merge analyses so shared libs are only collected once
MERGE(
(a, 'chimpstackr', 'chimpstackr'),
(a_cli, 'chimpstackr-cli', 'chimpstackr-cli'),
)
# ── GUI Executable ──
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
gui_exe = EXE(
pyz,
a.scripts,
[],
exclude_binaries=True,
name='chimpstackr',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=False, # UPX can cause antivirus false positives
console=False, # No terminal window
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
icon=['packaging/icons/icon.ico'] if sys.platform == 'win32'
else ['packaging/icons/chimpstackr_icon.icns'] if sys.platform == 'darwin'
else ['packaging/icons/icon_512x512.png'],
)
# ── CLI Executable ──
pyz_cli = PYZ(a_cli.pure, a_cli.zipped_data, cipher=block_cipher)
cli_exe = EXE(
pyz_cli,
a_cli.scripts,
[],
exclude_binaries=True,
name='chimpstackr-cli',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=False,
console=True, # Terminal window for CLI
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
)
# ── Collect into single directory ──
coll = COLLECT(
gui_exe,
a.binaries,
a.zipfiles,
a.datas,
cli_exe,
a_cli.binaries,
a_cli.zipfiles,
a_cli.datas,
strip=False,
upx=False,
upx_exclude=[],
name='chimpstackr',
)
# ── macOS .app bundle (GUI only) ──
if sys.platform == 'darwin':
app = BUNDLE(
coll,
name='ChimpStackr.app',
icon='packaging/icons/chimpstackr_icon.icns',
bundle_identifier='noah.peeters.chimpstackr',
info_plist={
'CFBundleName': 'ChimpStackr',
'CFBundleDisplayName': 'ChimpStackr',
'CFBundleShortVersionString': _ver.lstrip('v'),
'CFBundleVersion': _ver.lstrip('v'),
'NSHighResolutionCapable': True,
'NSRequiresAquaSystemAppearance': False, # Support dark mode
'LSMinimumSystemVersion': '11.0',
'CFBundleDocumentTypes': [
{
'CFBundleTypeName': 'Image Files',
'CFBundleTypeRole': 'Viewer',
'LSItemContentTypes': [
'public.image',
'public.jpeg',
'public.png',
'public.tiff',
'com.adobe.raw-image',
],
},
],
},
)