-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathheadmatch.spec
More file actions
236 lines (214 loc) · 6.65 KB
/
Copy pathheadmatch.spec
File metadata and controls
236 lines (214 loc) · 6.65 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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
# -*- mode: python ; coding: utf-8 -*-
"""PyInstaller spec for HeadMatch GUI — Linux x64 single-file binary.
Build with: pyinstaller headmatch.spec
Or use: python scripts/build.py
"""
import os
import sys
from pathlib import Path
block_cipher = None
# ── Collect BLAS/LAPACK shared libraries from numpy/scipy ──
# pip-installed wheels bundle their own OpenBLAS in .libs directories.
# PyInstaller's hooks usually find these, but we add them explicitly
# as a safety net for cross-distro compatibility.
_blas_libs = []
for pkg_name in ('numpy', 'scipy'):
try:
pkg = __import__(pkg_name)
pkg_dir = os.path.dirname(pkg.__file__)
# Check .libs directory (pip wheel layout)
libs_dir = os.path.join(pkg_dir, '.libs')
if os.path.isdir(libs_dir):
for f in os.listdir(libs_dir):
full = os.path.join(libs_dir, f)
if os.path.isfile(full) and ('.so' in f or '.dylib' in f):
_blas_libs.append((full, '.'))
# Also check for .so files directly in the package (some builds)
for root, _dirs, files in os.walk(pkg_dir):
for f in files:
if ('openblas' in f.lower() or 'lapack' in f.lower()) and ('.so' in f or '.dylib' in f):
full = os.path.join(root, f)
if os.path.isfile(full):
_blas_libs.append((full, '.'))
except ImportError:
pass
# Deduplicate by basename
_seen = set()
_deduped = []
for src, dst in _blas_libs:
name = os.path.basename(src)
if name not in _seen:
_seen.add(name)
_deduped.append((src, dst))
_blas_libs = _deduped
print(f"Bundling {len(_blas_libs)} BLAS/LAPACK libraries from pip packages")
for src, _ in _blas_libs:
print(f" {src}")
# Collect example target CSVs as data files
example_targets = []
targets_dir = os.path.join('docs', 'examples', 'targets')
if os.path.isdir(targets_dir):
for f in os.listdir(targets_dir):
if f.endswith('.csv'):
example_targets.append(
(os.path.join(targets_dir, f), os.path.join('docs', 'examples', 'targets'))
)
from PyInstaller.utils.hooks import collect_submodules
# Collect tkinter — it's a stdlib C extension that PyInstaller may miss.
# On some systems (e.g. Python 3.14 minimal installs) tkinter may not
# be available at all; guard the collection.
tkinter_hiddenimports = []
_tcl_tk_datas = []
try:
tkinter_hiddenimports = collect_submodules('tkinter')
except Exception:
print("WARNING: tkinter not found — GUI binary may not work. Install python3-tkinter.")
# Try to find Tcl/Tk data directories
try:
import tkinter as _tk
_root = _tk.Tk(useTk=False)
_tcl_root = _root.tk.eval('info library')
_root.destroy()
if _tcl_root and os.path.isdir(_tcl_root):
_tcl_tk_datas.append((_tcl_root, 'tcl'))
_tk_root = os.path.join(os.path.dirname(_tcl_root), 'tk' + _tk.TkVersion.__str__() if hasattr(_tk, 'TkVersion') else '')
if _tk_root and os.path.isdir(_tk_root):
_tcl_tk_datas.append((_tk_root, 'tk'))
except Exception:
pass
a = Analysis(
['scripts/entry_gui.py'],
pathex=['.'],
binaries=_blas_libs,
datas=example_targets + _tcl_tk_datas,
hiddenimports=tkinter_hiddenimports + [
'headmatch',
'headmatch.cli',
'headmatch.gui',
'headmatch.gui_views',
'headmatch.audio_backend',
'headmatch.backend_pipewire',
'headmatch.measure',
'headmatch.pipeline',
'headmatch.pipeline_artifacts',
'headmatch.pipeline_confidence',
'headmatch.analysis',
'headmatch.peq',
'headmatch.signals',
'headmatch.targets',
'headmatch.target_editor',
'scipy.interpolate',
'headmatch.exporters',
'headmatch.plots',
'headmatch.io_utils',
'headmatch.settings',
'headmatch.contracts',
'headmatch.paths',
'headmatch.history',
'headmatch.app_identity',
'headmatch.apo_import',
'headmatch.apo_refine',
'headmatch.headphone_db',
'headmatch.desktop',
'headmatch.troubleshooting',
'sounddevice',
],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=['matplotlib', 'IPython', 'notebook', 'pytest'],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False,
)
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
exe = EXE(
pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
[],
name='headmatch-gui',
debug=False,
bootloader_ignore_signals=False,
strip=True,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=False, # GUI app — no terminal window
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
)
# ── CLI binary ──
cli_a = Analysis(
['scripts/entry_cli.py'],
pathex=['.'],
binaries=_blas_libs,
datas=example_targets,
hiddenimports=[
'headmatch',
'headmatch.cli',
'headmatch.audio_backend',
'headmatch.backend_pipewire',
'headmatch.measure',
'headmatch.pipeline',
'headmatch.pipeline_artifacts',
'headmatch.pipeline_confidence',
'headmatch.analysis',
'headmatch.peq',
'headmatch.signals',
'headmatch.targets',
'headmatch.target_editor',
'scipy.interpolate',
'headmatch.exporters',
'headmatch.plots',
'headmatch.io_utils',
'headmatch.settings',
'headmatch.contracts',
'headmatch.paths',
'headmatch.history',
'headmatch.app_identity',
'headmatch.apo_import',
'headmatch.apo_refine',
'headmatch.headphone_db',
'headmatch.desktop',
'headmatch.troubleshooting',
'sounddevice',
'headmatch.tui',
],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=['matplotlib', 'IPython', 'notebook', 'pytest'],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False,
)
cli_pyz = PYZ(cli_a.pure, cli_a.zipped_data, cipher=block_cipher)
cli_exe = EXE(
cli_pyz,
cli_a.scripts,
cli_a.binaries,
cli_a.zipfiles,
cli_a.datas,
[],
name='headmatch',
debug=False,
bootloader_ignore_signals=False,
strip=True,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=True, # CLI needs terminal
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
)