FIX: verify_bundle.py false-positive Windows - TOC Python literal double-escape backslash (app\\static -> app//static), normalize 2 buoc
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user