Skip to content

The agent that grows with you

fix(pm): drop x64 vcruntime140_1.dll pre-publish so the recorded digest matches shipped bytes

ethernet5db212451503
diff --git a/.github/workflows/desktop-bundled-release.yml b/.github/workflows/desktop-bundled-release.yml
index 8b696c844e8..ce0ed7ecf14 100644
--- a/.github/workflows/desktop-bundled-release.yml
+++ b/.github/workflows/desktop-bundled-release.yml
@@ -278,9 +278,9 @@ jobs:
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: apps/desktop/build/agent-payload/tools
- key: pm-store-${{ matrix.target.label }}-${{ hashFiles('pm/lock.json', 'uv.lock') }}
+ key: pm-store-v2-${{ matrix.target.label }}-${{ hashFiles('pm/lock.json', 'uv.lock') }}
restore-keys: |
- pm-store-${{ matrix.target.label }}-
+ pm-store-v2-${{ matrix.target.label }}-
- name: Resolve electron's default download cache path
shell: bash
diff --git a/.github/workflows/pm-bundle.yml b/.github/workflows/pm-bundle.yml
index c0a69c1aa26..87bdf850687 100644
--- a/.github/workflows/pm-bundle.yml
+++ b/.github/workflows/pm-bundle.yml
@@ -73,7 +73,7 @@ jobs:
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: build/agent-payload/tools
- key: pm-store-${{ matrix.target.label }}-${{ hashFiles('pm/lock.json', 'uv.lock') }}
+ key: pm-store-v2-${{ matrix.target.label }}-${{ hashFiles('pm/lock.json', 'uv.lock') }}
# win32-arm64 builds cryptography from sdist (no win_arm64 wheel);
# its Rust core links OpenSSL statically from vcpkg.
diff --git a/pm/cli.py b/pm/cli.py
index 363026978c5..b786613943a 100644
--- a/pm/cli.py
+++ b/pm/cli.py
@@ -108,17 +108,6 @@ def _bundle_package_names() -> list[str]:
return names
-def _drop_unloadable_runtime_files(store_dir: Path) -> None:
- """Drop the x64 VC runtime that python-build-standalone ships beside ARM64 Python."""
- if current_target() != "win32-arm64":
- return
- facts = _facts()
- facts.reload()
- python = facts.get("python")
- if python and "entry" in python:
- (store_dir / python["entry"] / "vcruntime140_1.dll").unlink(missing_ok=True)
-
-
def cmd_install(args) -> int:
names = args.names or [
n for n in _lockfile().names() if not get_package(n).optional
@@ -577,12 +566,10 @@ def cmd_bundle(args) -> int:
os.environ["HERMES_RUNTIME_DIR"] = str(store_dir)
paths._stamp.cache_clear()
- failed = 0
names = _bundle_package_names()
- failed += _install_names(
+ failed = _install_names(
[n for n in names if get_package(n).missing_reason(current_target()) is None]
)
- _drop_unloadable_runtime_files(store_dir)
# Prune the staged store BEFORE the venv sync and packaging: drop the
# fetch-<sha> download-cache archives (needed only at install time — dead
diff --git a/pm/packages.py b/pm/packages.py
index b472e117d4f..c27efe0577e 100644
--- a/pm/packages.py
+++ b/pm/packages.py
@@ -194,6 +194,13 @@ class Python(BinaryPackage):
binary = self.binary(staged, target)
if binary is not None:
_macos_sign_managed_python(binary)
+ # python-build-standalone ships the x64 VC runtime (vcruntime140_1.dll)
+ # beside ARM64 Windows Python; it cannot load on ARM64 and would fail
+ # the arch guard. Drop it HERE, before publish: the tree digest is
+ # recorded over the shipped bytes, so a post-publish deletion (as the
+ # old bundle-time drop did) makes doctor's re-hash mismatch.
+ if target == "win32-arm64":
+ (staged / "vcruntime140_1.dll").unlink(missing_ok=True)
def fetch_url(self, version: str, target: str) -> str:
# lock version is "<python>+<release tag>", e.g. "3.11.13+202****0807"
diff --git a/tests/pm/test_pm_core.py b/tests/pm/test_pm_core.py
index dfa893f42b1..9f5fe77a78d 100644
--- a/tests/pm/test_pm_core.py
+++ b/tests/pm/test_pm_core.py
@@ -735,43 +735,34 @@ def test_arch_guard_allows_emulated_x64_on_win32_arm64(monkeypatch, tmp_path):
assert problems == []
-def test_drop_unloadable_runtime_files_removes_only_arm64_x64_vc_runtime(monkeypatch, tmp_path):
- import pm.cli as cli
+def test_python_stage_drops_unloadable_x64_vc_runtime_on_arm64(monkeypatch, tmp_path):
+ import pm.packages as packages
+ from pm.registry import get_package
- store = tmp_path / "store"
- entry = store / "python-3.11-win32-arm64"
- entry.mkdir(parents=True)
- stray = entry / "vcruntime140_1.dll"
- keep = entry / "vcruntime140.dll"
- stray.write_bytes(b"x64")
- keep.write_bytes(b"arm64")
- facts = Facts(store / "facts.json")
- facts.record("python", "3.11", entry.name, {}, store)
+ staged = tmp_path / "staged"
+ staged.mkdir()
+ (staged / "vcruntime140_1.dll").write_bytes(b"x64")
+ (staged / "vcruntime140.dll").write_bytes(b"arm64")
- monkeypatch.setattr(cli, "_facts", lambda: facts)
- monkeypatch.setattr(cli, "current_target", lambda: "win32-arm64")
- cli._drop_unloadable_runtime_files(store)
+ monkeypatch.setattr(packages, "_macos_sign_managed_python", lambda p: False)
+ get_package("python").stage(None, staged, "3.11.16", "win32-arm64")
- assert not stray.exists()
- assert keep.is_file()
+ assert not (staged / "vcruntime140_1.dll").exists()
+ assert (staged / "vcruntime140.dll").is_file()
-def test_drop_unloadable_runtime_files_keeps_other_targets(monkeypatch, tmp_path):
- import pm.cli as cli
+def test_python_stage_keeps_vc_runtimes_on_other_targets(monkeypatch, tmp_path):
+ import pm.packages as packages
+ from pm.registry import get_package
- store = tmp_path / "store"
- entry = store / "python-3.11-win32-x64"
- entry.mkdir(parents=True)
- runtime = entry / "vcruntime140_1.dll"
- runtime.write_bytes(b"x64")
- facts = Facts(store / "facts.json")
- facts.record("python", "3.11", entry.name, {}, store)
+ staged = tmp_path / "staged"
+ staged.mkdir()
+ (staged / "vcruntime140_1.dll").write_bytes(b"x64")
- monkeypatch.setattr(cli, "_facts", lambda: facts)
- monkeypatch.setattr(cli, "current_target", lambda: "win32-x64")
- cli._drop_unloadable_runtime_files(store)
+ monkeypatch.setattr(packages, "_macos_sign_managed_python", lambda p: False)
+ get_package("python").stage(None, staged, "3.11.16", "win32-x64")
- assert runtime.is_file()
+ assert (staged / "vcruntime140_1.dll").is_file()
def test_verify_missing_binary_reports_path_and_listing(tmp_path):