Repository navigation
Expand file tree
/
Copy pathrecall.spec
More file actions
209 lines (191 loc) · 5.97 KB
/
Copy pathrecall.spec
File metadata and controls
209 lines (191 loc) · 5.97 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
# -*- mode: python ; coding: utf-8 -*-
"""PyInstaller spec for Recall.
Build: pyinstaller recall.spec
Output: dist/Recall/Recall.exe (Windows)
dist/Recall/Recall (macOS / Linux)
Phase 5J: Tier A excludes applied. Pruning out unused weight by
both submodule excludes (Python-level) and binary filter (DLL-level
post-Analysis). The savings target is ~309 MB unpacked / ~80 MB
compressed. See `docs/engineering/INSTALL_SIZE_AUDIT_V2.md` for
the byte-by-byte rationale.
Notes:
- `chromadb` and `sentence_transformers` import many submodules
dynamically; `collect_submodules` is the reliable way to bundle
them without runtime ImportError surprises.
- The embedding model (~80 MB) is NOT bundled. First run downloads
it into the HF cache; subsequent runs use `local_files_only=True`.
- An app icon at `app/assets/icon.ico` is picked up automatically.
"""
import os
from PyInstaller.utils.hooks import collect_data_files, collect_submodules
block_cipher = None
icon_path = os.path.join("app", "assets", "icon.ico")
icon_arg = icon_path if os.path.exists(icon_path) else None
hiddenimports = (
collect_submodules("chromadb")
+ collect_submodules("sentence_transformers")
+ collect_submodules("transformers")
+ collect_submodules("tokenizers")
+ collect_submodules("pynput")
+ collect_submodules("watchdog")
)
datas = (
collect_data_files("chromadb")
+ collect_data_files("sentence_transformers")
+ collect_data_files("tokenizers")
)
# Tier A excludes — Python-level. These submodules are never
# imported on any Recall code path; the audit (`INSTALL_SIZE_AUDIT_V2`)
# names each. Excluding them at the Python level prevents
# PyInstaller's hooks from pulling associated binaries.
TIER_A_EXCLUDES = [
# Dev / interactive tools — never on a release path
"tkinter",
"matplotlib",
"IPython",
"jupyter",
"notebook",
# PyArrow — transitive via huggingface_hub for `datasets` only;
# Recall does not call into datasets. ~88 MB on disk.
"pyarrow",
# FFmpeg binaries via imageio_ffmpeg — Recall has no media path.
# ~88 MB on disk.
"imageio_ffmpeg",
"imageio",
# PyQt6 modules Recall does not use — Quick / QML / 3D / PDF /
# Designer. Recall is QtWidgets only.
"PyQt6.QtQuick",
"PyQt6.QtQuickWidgets",
"PyQt6.QtQuick3D",
"PyQt6.QtQuickControls2",
"PyQt6.QtQml",
"PyQt6.QtQmlModels",
"PyQt6.QtQmlWorkerScript",
"PyQt6.QtPdf",
"PyQt6.QtPdfWidgets",
"PyQt6.QtDesigner",
"PyQt6.QtMultimedia",
"PyQt6.QtMultimediaWidgets",
"PyQt6.QtWebEngineCore",
"PyQt6.QtWebEngineWidgets",
"PyQt6.QtWebChannel",
"PyQt6.QtCharts",
"PyQt6.QtDataVisualization",
"PyQt6.QtSerialPort",
"PyQt6.QtSensors",
"PyQt6.QtBluetooth",
"PyQt6.QtNfc",
"PyQt6.QtPositioning",
"PyQt6.QtLocation",
"PyQt6.QtTextToSpeech",
]
# Tier A binary filter — DLLs Qt6 ships that the Python-level
# excludes do not catch because they are loaded via Qt's plugin
# system. Patterns are matched against the destination path (case
# insensitive). The filter runs against `a.binaries` and `a.datas`
# before COLLECT - bundle never sees them.
TIER_A_BIN_PATTERNS = [
# Qt Quick / QML / 3D / Pdf / Designer DLLs
"qt6quick",
"qt6qml",
"qt6pdf",
"qt6designer",
"qt63d",
"qt6multimedia",
"qt6webengine",
"qt6webchannel",
"qt6charts",
"qt6datavisualization",
"qt6serialport",
"qt6sensors",
"qt6bluetooth",
"qt6nfc",
"qt6positioning",
"qt6location",
"qt6texttospeech",
# Software OpenGL fallback (~20 MB; Recall uses HW Qt rendering)
"opengl32sw.dll",
# FFmpeg multimedia codecs (~30 MB combined). Recall has no
# media path; Qt Multimedia is already excluded above; these
# are the underlying codec DLLs Qt would dlopen.
"avcodec-",
"avformat-",
"avutil-",
"swresample-",
"swscale-",
# Qt Quick plugins / qmldir trees (under qml/, plugins/quick*)
"qt6/qml/",
"pyqt6/qt6/qml/",
"/plugins/quick",
# Qt PDF plugin
"/plugins/pdf",
# pyarrow native binaries (the Python-level exclude catches the
# python import; this catches any straggler DLL/native module).
"pyarrow/",
"/pyarrow.libs/",
# imageio_ffmpeg binaries
"imageio_ffmpeg/",
]
def _excluded_binary(dest: str) -> bool:
"""True when the destination path matches a Tier A drop pattern."""
p = dest.replace("\\", "/").lower()
return any(pat in p for pat in TIER_A_BIN_PATTERNS)
a = Analysis(
["recall.py"],
pathex=[],
binaries=[],
datas=datas,
hiddenimports=hiddenimports,
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=TIER_A_EXCLUDES,
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False,
)
# Phase 5J — apply the post-Analysis binary filter. Each TOC entry
# is `(dest, source, kind)`; keep entries that don't match any
# drop pattern. Print a one-line summary so the build log carries
# the receipt.
_before_bin = len(a.binaries)
_before_data = len(a.datas)
a.binaries = [t for t in a.binaries if not _excluded_binary(t[0])]
a.datas = [t for t in a.datas if not _excluded_binary(t[0])]
print(
f"[recall.spec] Tier A binary filter: "
f"binaries {_before_bin} -> {len(a.binaries)} "
f"({_before_bin - len(a.binaries)} dropped); "
f"datas {_before_data} -> {len(a.datas)} "
f"({_before_data - len(a.datas)} dropped)"
)
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
exe = EXE(
pyz,
a.scripts,
[],
exclude_binaries=True,
name="Recall",
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=False,
console=False,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
icon=icon_arg,
)
coll = COLLECT(
exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=False,
upx_exclude=[],
name="Recall",
)