Skip to content

The agent that grows with you

fix(build): shorten native wheel cache partitions for MSVC

ethernete418f17fbb4f
diff --git a/docs/shared-bundle-builds.md b/docs/shared-bundle-builds.md
index f130b42550f..2411722a86e 100644
--- a/docs/shared-bundle-builds.md
+++ b/docs/shared-bundle-builds.md
@@ -99,6 +99,14 @@ successful preparation, before product compilation or signing. Failed
preparation leaves completed provider data locally but does not save an overall
snapshot. The general `setup-pm` action remains available for other workflows.
+Native wheel caches use compact 128-bit partitions under `python/runtime`, keyed
+by the target and observed compiler/SDK inputs. Missing identities still get a
+fresh partition. uv builds source distributions inside this cache, so partition
+names must leave room for nested compiler outputs below Windows `MAX_PATH`.
+Keep a custom `--cache` root short as well; enabling OS long paths does not make
+every native compiler long-path aware. This layout retains the shared cache
+transport and all target-compatible extras, including Silk.
+
The strict boundary forbids dependency acquisition during consumption, not all
network access: signing, timestamping, notarization and publication retain their
online responsibilities. A network-denied unsigned native build is still needed
diff --git a/scripts/bundles/desktop_toolchain.py b/scripts/bundles/desktop_toolchain.py
index e014df989c2..5940ccf824f 100644
--- a/scripts/bundles/desktop_toolchain.py
+++ b/scripts/bundles/desktop_toolchain.py
@@ -179,8 +179,10 @@ def native_cache_path(cache: Path, env: Mapping[str, str]) -> Path:
encoded = json.dumps(identity, sort_keys=True)
owned = str(cache.resolve())
encoded = encoded.replace(json.dumps(owned)[1:-1], "<build-cache>")
- digest = hashlib.sha256(encoded.encode()).hexdigest() if complete else uuid.uuid4().hex
- return cache.resolve() / "python/runtime" / f"native-{target}-{digest}"
+ # uv builds sdists below this root. Keep the partition compact so compiler
+ # outputs fit Windows MAX_PATH; the target is already part of the identity.
+ digest = hashlib.sha256(encoded.encode()).hexdigest()[:32] if complete else uuid.uuid4().hex
+ return cache.resolve() / "python/runtime" / digest
if __name__ == "__main__":
diff --git a/tests/scripts/test_desktop_toolchain.py b/tests/scripts/test_desktop_toolchain.py
index f73a937c2e9..e8b682ee611 100644
--- a/tests/scripts/test_desktop_toolchain.py
+++ b/tests/scripts/test_desktop_toolchain.py
@@ -244,6 +244,40 @@ def test_native_cache_identity_tracks_compilers_sdk_and_openssl(tmp_path, monkey
assert desktop_toolchain.native_cache_path(cache, env) != desktop_toolchain.native_cache_path(cache, env)
[email protected]("complete", [False, True])
+def test_native_cache_leaves_room_for_sdist_compiler_outputs(tmp_path, monkeypatch, complete):
+ from pathlib import PureWindowsPath
+ from scripts.bundles import desktop_toolchain
+
+ # Replay the Windows CI layout as path data, without faking the host OS.
+ # uv builds in its cached sdist; /Fo is relative to that working directory.
+ cache = tmp_path / "cache"
+ desktop_toolchain.platform.platform()
+
+ def probe(*args, **kwargs):
+ if not complete:
+ raise FileNotFoundError()
+ return SimpleNamespace(returncode=0, stdout="compiler identity", stderr="")
+
+ openssl = cache / "native/openssl"
+ for name in ("include/openssl/opensslv.h", "lib/libcrypto.lib"):
+ path = openssl / name
+ path.parent.mkdir(parents=True, exist_ok=True)
+ path.write_bytes(b"native input")
+ monkeypatch.setattr(desktop_toolchain.subprocess, "run", probe)
+ selected = desktop_toolchain.native_cache_path(cache, {
+ "WindowsSDKVersion": "10.0.1", "VCToolsVersion": "14.1", "OPENSSL_DIR": str(openssl),
+ })
+ assert selected.is_relative_to(cache / "python/runtime")
+ runner_cache = PureWindowsPath("D:/a/hermes-agent/hermes-agent/.cache/desktop-inputs")
+ sdist = PureWindowsPath("sdists-v9/pypi/pilk/0.2.4/5b4cbVXt0GPuGQrp/src")
+ for architecture in ("win-amd64", "win-arm64"):
+ output = (runner_cache.joinpath(*selected.relative_to(cache).parts) / sdist
+ / f"build/temp.{architecture}-cpython-314/Release/src/SKP_SILK_SRC"
+ / "SKP_Silk_NLSF_VQ_rate_distortion_FIX.obj")
+ assert len(str(output)) < 260, str(output)
+
+
@pytest.mark.parametrize("on_demand", [False, True])
def test_icon_environment_prepares_locked_group_before_generation(tmp_path, monkeypatch, on_demand):
import pm