From 83427fe5032e358f4503a49f44cf1450c8e908cc Mon Sep 17 00:00:00 2001 From: locpham Date: Sat, 8 Aug 2026 14:50:07 +0000 Subject: [PATCH] FIX: verify_bundle.py false-positive Windows - TOC Python literal double-escape backslash (app\\static -> app//static), normalize 2 buoc --- tools/verify_bundle.py | 6 ++++-- wiki.md | 8 +++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/tools/verify_bundle.py b/tools/verify_bundle.py index 139085e..c34fc5b 100644 --- a/tools/verify_bundle.py +++ b/tools/verify_bundle.py @@ -40,8 +40,10 @@ def main() -> int: with open(toc, "r", encoding="utf-8", errors="replace") as f: raw = f.read() # TOC Windows co the dung backslash (app\\static) — normalize het ve forward - # slash de kiem tra khong bi false positive. - text = raw.replace("\\", "/") + # slash de kiem tra khong bi false positive. TOC la Python literal nen + # backslash bi DOUBLE-escape ('app\\\\static') — thay 2 lan (\\\\ truoc, + # roi \\) de ca 2 dang deu ve '/'. + text = raw.replace("\\\\", "/").replace("\\", "/") missing = [] for req in REQUIRED: # Tim theo prefix thuc su trong TOC (vd 'app/static/js/...' hoac diff --git a/wiki.md b/wiki.md index ab487e2..bbd655d 100644 --- a/wiki.md +++ b/wiki.md @@ -1,4 +1,10 @@ -### [2026-08-08] FIX (LAN 3 - GOC ROOT): 'app\static does not exist' — sys.path thieu CWD khi chay 'pyinstaller' (entry point) +### [2026-08-08] FIX: verify_bundle.py vẫn false-positive trên Windows — TOC là Python literal nên backslash bị DOUBLE-escape ('app\\\\static') +- **Tóm tắt thay đổi:** Fix LAN 2 normalize `replace('\\','/')` 1 lần KHÔNG đủ: TOC file là Python literal (repr) → path Windows ghi thành `app\\\\static` (2 backslash trên disk) → replace 1 lần ra `app//static` → regex `app/static(?=[/'"])` không match → vẫn báo "Bundle thieu" DÙ bundle đủ. Fix: normalize 2 bước — `replace("\\\\","/")` (bắt double-escape) rồi `replace("\\","/")` (backslash đơn). Verify bằng TOC giả lập Windows repr: cả 2 entry match True. +- **Các file ảnh hưởng:** `tools/verify_bundle.py` (dòng normalize) +- **Ghi chú/Test (nếu có):** Test TOC Windows repr `'app\\\\static\\\\js\\\\app.js'` → normalize ra `app/static/js/app.js` → regex match. User: pull code mới rồi chạy lại build_windows.ps1 (bước 3.5 sẽ hết báo thiếu nếu bundle thực sự đủ). + +--- +### [2026-08-08] FIX (LAN 3 - GOC ROOT): 'app\\static does not exist' — sys.path thieu CWD khi chay 'pyinstaller' (entry point) - **Tóm tắt thay đổi:** Lỗi 'app\static does not exist' vẫn tái diễn dù đã 2 lần sửa datas (absolute path roi collect_data_files). Lần này tìm ra GOC ROOT THẬT SỰ: lệnh `pyinstaller engine.spec` (entry-point script cua PyInstaller) KHONG them CWD vao sys.path — chi `python -m PyInstaller` moi them. `collect_data_files('app')` import package 'app' qua sys.path -> khong thay -> tra ve [] AM THAM -> bundle thieu static/templates (dung canh: tren may dev chay `python -m PyInstaller` nen CWD co trong sys.path -> tuong da dung; may Windows chay `pyinstaller` -> CWD khong co -> collect rong -> TOC khong co app/static — dung voi loi verify cua user). Fix trong `engine.spec`: 1. `sys.path.insert(0, _SPEC_ROOT)` TRUOC khi goi collect_data_files — import 'app' luon hoạt dong bat ke CWD. 2. Fallback cuoi: neu collect_data_files van tra ve rong -> datas TINH absolute (app/templates, app/static, app/models) + in WARN de debug.