FIX (lan 2): bundle app assets qua collect_data_files (import-system) + fallback static dir trong main.py + verify TOC trong build_windows.ps1

This commit is contained in:
2026-08-08 13:59:35 +00:00
parent b78a629429
commit eaca051191
4 changed files with 62 additions and 12 deletions
+12 -12
View File
@@ -9,20 +9,20 @@ from PyInstaller.utils.hooks import collect_dynamic_libs, collect_submodules, co
binaries = collect_dynamic_libs('pedalboard')
binaries += collect_dynamic_libs('soundfile')
# Root tuyet doi cua thu muc chua spec — datas PHẢI absolute: PyInstaller
# resolve duong dan relative theo CWD luc chay lenh (KHONG theo spec file),
# chay tu noi khac -> khong tim thay -> bo qua am tham -> app/static thieu
# trong bundle -> RuntimeError 'app\static does not exist' luc chay (da gap).
# Root tuyet doi cua thu muc chua spec — dung cho cac datas KHONG nam trong
# package 'app' (vd thu muc md/). Cac assets cua app (static/templates/models)
# duoc bundle qua collect_data_files('app') — PyInstaller tu tim qua import
# system, KHONG phu thuoc CWD/SPECPATH khi chay lenh (da gap 2 lan: chay
# pyinstaller tu noi khac -> relative path khong resolve -> app/static thieu
# trong bundle -> RuntimeError 'app\\static does not exist' luc chay).
_SPEC_ROOT = os.path.abspath(SPECPATH)
# Assets doc (read-only) + thu muc storage (khoi tao rong; khi frozen,
# config.py chuyen storage sang %APPDATA%\SonicForgeDAW\storage)
datas = [
(os.path.join(_SPEC_ROOT, 'app', 'templates'), 'app/templates'), # index.html, favicon.svg
(os.path.join(_SPEC_ROOT, 'app', 'static'), 'app/static'), # js/css/processors
(os.path.join(_SPEC_ROOT, 'app', 'models'), 'app/models'), # project_schema.json (projects.py)
(os.path.join(_SPEC_ROOT, 'app', 'storage'), 'app/storage'),
(os.path.join(_SPEC_ROOT, 'md'), 'md'), # /ai-prompt-generator
# Assets cua app: bundle QUA IMPORT SYSTEM (collect_data_files) — an toan nhat.
# Loai tru storage (57MB soundfonts/uploads — vo ich trong onefile, config.py
# da chuyen storage sang %APPDATA%\\SonicForgeDAW khi frozen) va __pycache__.
datas = collect_data_files('app', excludes=['**/storage/**', '**/__pycache__/**', '**/*.pyc'])
datas += [
(os.path.join(_SPEC_ROOT, 'md'), 'md'), # /ai-prompt-generator (doc, ngoai package app)
]
# librosa 0.11 dùng lazy_loader.attach_stub -> lúc RUNTIME cần file .pyi