-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFunscriptForge.spec
More file actions
268 lines (241 loc) · 7.76 KB
/
FunscriptForge.spec
File metadata and controls
268 lines (241 loc) · 7.76 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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
# -*- mode: python ; coding: utf-8 -*-
#
# PyInstaller spec for FunscriptForge desktop app.
#
# Build with:
# pyinstaller FunscriptForge.spec --clean
#
# Output: dist/FunscriptForge/ (one-folder bundle)
# Entry point: dist/FunscriptForge/FunscriptForge.exe (or .app, or .bin)
#
# Design notes: internal/design/desktop_app.md
import sys
from pathlib import Path
from PyInstaller.utils.hooks import (
collect_all,
collect_data_files,
collect_submodules,
copy_metadata,
)
# ── Paths ──────────────────────────────────────────────────────────────
SPEC_DIR = Path(SPECPATH).resolve()
APP_DIR = SPEC_DIR
FT_SIBLING = SPEC_DIR.parent / "funscript-tools"
FUC_SIBLING = SPEC_DIR.parent / "forge-ui-components"
if not FT_SIBLING.exists():
raise SystemExit(
f"ERROR: funscript-tools not found at {FT_SIBLING}\n"
"Clone it next to funscript-updater: git clone <repo> ../funscript-tools"
)
if not FUC_SIBLING.exists():
raise SystemExit(
f"ERROR: forge-ui-components not found at {FUC_SIBLING}\n"
"Clone it next to funscript-updater."
)
# ── Streamlit collection (the tricky part) ────────────────────────────
streamlit_datas, streamlit_binaries, streamlit_hiddenimports = collect_all("streamlit")
# Streamlit uses importlib.metadata to discover itself at runtime
streamlit_datas += copy_metadata("streamlit")
# Other packages that use metadata or dynamic imports
extra_metadata = []
for pkg in (
"streamlit",
"altair",
"pyarrow",
"numpy",
"pandas",
"matplotlib",
"pydeck",
"tornado",
"click",
"rich",
):
try:
extra_metadata += copy_metadata(pkg)
except Exception:
pass # Skip any that aren't installed
# Top-level packages and modules in this repo that the runtime needs.
_CODE_PACKAGES = [
"forge",
"ui",
"assessment",
"catalog",
"pattern_catalog",
"visualizations",
"user_customization",
"plugins",
]
_CODE_MODULES = [
"utils.py",
"models.py",
"cli.py",
]
# Hidden imports Streamlit needs at runtime
hidden_imports = list(streamlit_hiddenimports) + [
"streamlit.web.cli",
"streamlit.runtime.scriptrunner.magic_funcs",
"streamlit.runtime.caching",
"streamlit.runtime.state",
"streamlit.components.v1",
"altair",
"pyarrow",
"pydeck",
"watchdog",
"importlib_metadata",
]
# FunscriptForge submodules
for pkg in _CODE_PACKAGES:
try:
hidden_imports += collect_submodules(pkg)
except Exception:
pass
hidden_imports += collect_submodules("forge_ui_components")
# Top-level modules that are imported bare (from X import Y)
hidden_imports += ["models", "utils"]
# ── Data files ─────────────────────────────────────────────────────────
datas = list(streamlit_datas) + list(extra_metadata)
for pkg in _CODE_PACKAGES:
datas += [(str(APP_DIR / pkg), pkg)]
for mod in _CODE_MODULES:
p = APP_DIR / mod
if p.exists():
datas += [(str(p), ".")]
# Static asset folders
datas += [
(str(APP_DIR / "media"), "media"),
# Streamlit theme config — dark theme, upload limit
(str(APP_DIR / ".streamlit" / "config.toml"), ".streamlit"),
]
# assets/ — only the tone_cards and samples subfolders. The root assets/
# may contain test output (e.g. VictoriaOaks_stingy/) that we must not ship.
for _sub in ("tone_cards", "samples"):
_p = APP_DIR / "assets" / _sub
if _p.exists():
datas += [(str(_p), f"assets/{_sub}")]
# demo/ — only the examples subfolder (funscripts + README), never the
# bundled video file (725 MB) or test .forge output. The post-build
# hook copies the same files NEXT TO the exe for visibility.
_demo_examples = APP_DIR / "demo" / "examples"
if _demo_examples.exists():
datas += [(str(_demo_examples), "demo/examples")]
# Device specs + other JSON config
datas += [
(str(APP_DIR / "forge" / "device_specs.json"), "forge"),
]
# forge-ui-components (editable install — copy source into bundle)
datas += [
(str(FUC_SIBLING / "forge_ui_components"), "forge_ui_components"),
]
# Vendored funscript-tools
datas += [
(str(FT_SIBLING), "_vendored/funscript_tools"),
]
# matplotlib and pymediainfo data
try:
datas += collect_data_files("matplotlib")
except Exception:
pass
try:
datas += collect_data_files("pymediainfo")
except Exception:
pass
# ── Binaries ───────────────────────────────────────────────────────────
binaries = list(streamlit_binaries)
# ── PyInstaller pipeline ───────────────────────────────────────────────
block_cipher = None
# Platform-specific icon resolution
if sys.platform == "win32":
_icon_path = str(APP_DIR / "media" / "funscriptforge.ico")
elif sys.platform == "darwin":
_icns = APP_DIR / "media" / "funscriptforge.icns"
_icon_path = str(_icns) if _icns.exists() else None
else:
_icon_path = None
a = Analysis(
["desktop.py"],
pathex=[str(APP_DIR), str(FUC_SIBLING)],
binaries=binaries,
datas=datas,
hiddenimports=hidden_imports,
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[
# Strip heavy packages that aren't used at runtime
"tkinter",
"PyQt5",
"PyQt6",
"PySide2",
"PySide6",
"notebook",
"jupyter",
"IPython",
"pytest",
"sphinx",
],
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,
[],
exclude_binaries=True,
name="FunscriptForge",
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=False, # UPX can cause antivirus false positives
console=False, # no console window on Windows
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
icon=_icon_path,
)
coll = COLLECT(
exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=False,
upx_exclude=[],
name="FunscriptForge",
)
# macOS .app bundle wrapper
if sys.platform == "darwin":
app = BUNDLE(
coll,
name="FunscriptForge.app",
icon=_icon_path,
bundle_identifier="com.liquidreleasing.funscriptforge",
)
# ── Post-build: copy demo files NEXT TO the exe (not inside _internal) ──
# So users immediately see a `demo/examples/` folder beside FunscriptForge.exe
# and can find the sample funscripts without digging into _internal.
# IMPORTANT: skip large media (.mov/.mp4/.wav/.forge/) — the demo video
# and any test-run output folders must not ship.
import shutil as _shutil
_dist_app = SPEC_DIR / "dist" / "FunscriptForge"
_demo_src = SPEC_DIR / "demo"
_demo_dst = _dist_app / "demo"
def _skip_demo(dir_path: str, names: list) -> list:
skipped = []
for name in names:
if name in (".forge", "__pycache__"):
skipped.append(name)
continue
lower = name.lower()
if lower.endswith((".mov", ".mp4", ".mkv", ".webm", ".wav", ".m4a")):
skipped.append(name)
return skipped
if _demo_src.exists() and _dist_app.exists():
if _demo_dst.exists():
_shutil.rmtree(_demo_dst)
_shutil.copytree(_demo_src, _demo_dst, ignore=_skip_demo)
print(f"Copied demo files to {_demo_dst} (media/test output excluded)")