From 05b8f7f7e973ecd0c4efcb174ded6134b518f316 Mon Sep 17 00:00:00 2001 From: argszero Date: Wed, 5 Aug 2026 01:25:24 +0800 Subject: [PATCH] =?UTF-8?q?emrg:=20build-release=20=E5=8D=81=E4=B8=80?= =?UTF-8?q?=E6=AC=A1=E4=BF=AE=E5=A4=8D=20=E2=80=94=20Windows=20python.exe?= =?UTF-8?q?=20=E6=8E=A2=E6=B5=8B=EF=BC=88rant=20#13=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 第 11 次实跑:3/4 平台成功(macOS + ubuntu×2,pipefail 修复生效), Windows 失败于 build-runtime.sh 第 4 步 pip install:exit 127(command not found)。 根因:Git Bash 对带路径的直接执行不做 .exe 补全。Windows 复制产物为 bin/python.exe(bin/python 无扩展名文件不存在),而脚本用 `"$DIST/bin/python"` (无扩展名)调用 → bash 找不到文件 → 127。POSIX 有 python 软链所以正常。 (bin/emrg.cmd 早已用 "%DIR%\python.exe",验证了引用方式差异。) 修复:PY_BIN 探测——bin/python 不存在且 bin/python.exe 存在时改用 .exe。 用 -e(存在性)而非 -x(可执行),cp 复制的 exe 执行位在 Git Bash 中不可靠。 验证: - bash -n OK - Windows(仅 python.exe)/ POSIX(仅 python 软链)双场景模拟正确 - 本机 macOS 实跑 build-runtime.sh 完整成功(83M runtime,pip deps 安装 OK) - pytest 464 passed;import checks OK --- packaging/build-runtime.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packaging/build-runtime.sh b/packaging/build-runtime.sh index c557d5b4..301a9f50 100755 --- a/packaging/build-runtime.sh +++ b/packaging/build-runtime.sh @@ -80,12 +80,18 @@ if [ -f "$ROOT/LICENSE" ]; then cp "$ROOT/LICENSE" "$DIST/source/LICENSE"; fi # ── 4. lib/(pip --target 全量含传递依赖,R3/R43)── echo "==> installing deps to lib/" -"$DIST/bin/python" -m pip install --quiet --target "$DIST/lib" \ +# Windows 复制产物为 python.exe(无扩展名 python 不存在,Git Bash 对带路径的 +# 直接执行不做 .exe 补全)→ 探测可执行名。POSIX 为软链 python。 +PY_BIN="$DIST/bin/python" +if [ ! -e "$PY_BIN" ] && [ -e "$PY_BIN.exe" ]; then + PY_BIN="$PY_BIN.exe" +fi +"$PY_BIN" -m pip install --quiet --target "$DIST/lib" \ rich httpx pyyaml jinja2 websockets # ── 5. assets/LICENSE/version ── cp "$ROOT/LICENSE" "$DIST/assets/LICENSE" 2>/dev/null || echo "Apache-2.0" > "$DIST/assets/LICENSE" -"$DIST/bin/python" -c "import emrg,sys; sys.path.insert(0,'$DIST/source'); import emrg as e; print(e.__version__)" > "$DIST/version.txt" 2>/dev/null \ +"$PY_BIN" -c "import emrg,sys; sys.path.insert(0,'$DIST/source'); import emrg as e; print(e.__version__)" > "$DIST/version.txt" 2>/dev/null \ || echo "0.2.0" > "$DIST/version.txt" echo "==> runtime size: $(du -sh "$DIST" | cut -f1)"