jim800121chen 4f316bb3b8 fix: wheels 目錄累積多版本導致 pip 解析失敗,app 啟動失敗
Windows 啟動卡在階段 2,pip 在 2 秒內失敗:

    ERROR: Cannot install certifi 2026.2.25 and certifi 2026.6.17
           because these package versions have conflicting dependencies.
    ERROR: ResolutionImpossible

根因:Makefile 的 vendor-wheels* 用 pip download --dest 但從不清空目錄,
payload-* 複製時也只疊上去不清。upstream 每發一次新版就多留一顆,於是
`pip install *.whl` 同時收到同一套件的多個版本,相依解析器立刻放棄。

vendor/wheels/darwin 目前 16 顆 = 9 個套件 + 7 顆重複舊版,與 log 的
「正在安裝 16 個 Python 套件」完全吻合。

三層修正:

1. ensurePythonRuntime 的 Auto 分支不再丟棄 bundled/system 的失敗原因。
   這是使用者連續三輪拿不到線索的原因 —— 它不是根因,是放大器。
   pip 的完整輸出本來就在 error 裡,只是被這裡擋掉。

2. selectLatestWheelPerPackage:送 pip 前每個套件只留最新版。這層才救得了
   已經出貨的安裝包,只修 Makefile 對使用者手上那包無效。套件名依 PEP 503
   正規化,版本用整數逐段比(避免 2.9 > 2.10 的字典序錯誤)。

3. Makefile 新增 clean_wheels_dir(沿用 copy_bundled_data 的路徑防護),
   vendor-wheels* 先清再下載、payload-* 複製前先清,從源頭杜絕。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-23 00:55:42 +08:00
..