The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(bundle): omit compressed build wheels from the payload cache
ethernetd6999fa8b849
diff --git a/scripts/bundles/native.py b/scripts/bundles/native.pyindex afd38409292..36b5b792d9c 100644--- a/scripts/bundles/native.py+++ b/scripts/bundles/native.py@@ -48,6 +48,19 @@ def _arch_guard(store_dir: Path) -> list[str]:+def stage_uv_cache(source: Path, destination: Path) -> None:+ """Keep extracted wheels for offline installs, not unsigned build ZIPs.++ The macOS signer reaches extracted native code, but not code inside ZIPs.+ uv installs built wheels from their extracted cache entries.+ """+ shutil.copytree(source, destination)+ for bucket in destination.glob("sdists-v*"):+ for wheel in bucket.rglob("*.whl"):+ if wheel.is_file():+ wheel.unlink()++def stage_native(args) -> int:previous = os.environ.get("HERMES_RUNTIME_DIR")try:@@ -164,7 +177,7 @@ def _stage_native(args) -> int:src_cache = bundle_uv_cache_dir()if src_cache.is_dir():print(f" uv-cache: copying {src_cache} → payload...", flush=True)- shutil.copytree(src_cache, payload_cache)+ stage_uv_cache(src_cache, payload_cache)print("✓ uv-cache (staged — warm rebuilds for the mutable venv)")else:print(" uv-cache: none warm (first bundle on this machine?)")diff --git a/tests/scripts/test_bundle_native.py b/tests/scripts/test_bundle_native.pyindex e4168d30b60..854187b579c 100644--- a/tests/scripts/test_bundle_native.py+++ b/tests/scripts/test_bundle_native.py@@ -6,6 +6,10 @@ import osimport shutilimport subprocessimport sys+import tarfile+import threading+from functools import partial+from http.server import SimpleHTTPRequestHandler, ThreadingHTTPServerfrom pathlib import Pathfrom types import SimpleNamespace@@ -55,3 +59,64 @@ def test_bundle_stages_git_tree_and_runs_native_children_before_manifest(tmp_patassert native.stage_native(SimpleNamespace(out=str(output), ref="HEAD")) == 1assert not (output / "manifest.json").exists()assert os.environ["HERMES_RUNTIME_DIR"] == str(tmp_path / "original")+++def test_staged_cache_installs_built_wheel_without_unsigned_zip(tmp_path):+ uv = shutil.which("uv")+ assert uv, "native bundle test requires uv"+ package = tmp_path / "package"+ package.mkdir()+ (package / "pyproject.toml").write_text(+ '[project]\nname="cache-proof"\nversion="1.0.0"\n'+ '[build-system]\nrequires=["setuptools"]\nbuild-backend="setuptools.build_meta"\n',+ encoding="utf-8",+ )+ (package / "cache_proof.py").write_text("VALUE = 'installed from cached wheel'\n", encoding="utf-8")+ dist = tmp_path / "dist"+ dist.mkdir()+ archive = dist / "cache_proof-1.0.0.tar.gz"+ with tarfile.open(archive, "w:gz") as source:+ source.add(package, arcname="cache_proof-1.0.0")+ cache = tmp_path / "build-cache"+ env = {**os.environ, "UV_CACHE_DIR": str(cache), "UV_NO_CONFIG": "1", "UV_PYTHON_DOWNLOADS": "never"}+ server = ThreadingHTTPServer(("127.0.0.1", 0), partial(SimpleHTTPRequestHandler, directory=str(dist)))+ thread = threading.Thread(target=server.serve_forever, daemon=True)+ thread.start()+ url = f"http://127.0.0.1:{server.server_port}/{archive.name}"+ try:+ subprocess.run(+ [uv, "pip", "install", "--python", sys.executable, "--target", str(tmp_path / "first"),+ "--no-build-isolation", "--no-deps", url],+ env=env, cwd=tmp_path, capture_output=True, text=True, check=True, timeout=60,+ )+ finally:+ server.shutdown()+ server.server_close()+ thread.join(timeout=5)+ assert list(cache.rglob("*.whl")), "the actual uv build must create the redundant ZIP"+ shipped = tmp_path / "payload/uv-cache"+ native.stage_uv_cache(cache, shipped)+ assert not list(shipped.rglob("*.whl"))+ assert list(cache.rglob("*.whl")), "the build machine's cache must not change"++ # The stopped server and absent source trees make a fallback build impossible.+ shutil.rmtree(dist)+ shutil.rmtree(package)+ shutil.rmtree(cache)+ for source in (shipped / "sdists-v9").rglob("src"):+ if source.is_dir():+ shutil.rmtree(source)+ installed = tmp_path / "installed"+ result = subprocess.run(+ [uv, "pip", "install", "--python", sys.executable, "--target", str(installed),+ "--no-deps", "--offline", url],+ env={**env, "UV_CACHE_DIR": str(shipped)}, cwd=tmp_path,+ capture_output=True, text=True, check=True, timeout=60,+ )+ assert "Building" not in result.stderr+ probe = subprocess.run(+ [sys.executable, "-c", "import cache_proof; print(cache_proof.VALUE)"],+ cwd=tmp_path, env={**env, "PYTHONPATH": str(installed)},+ capture_output=True, text=True, check=True, timeout=30,+ )+ assert probe.stdout.strip() == "installed from cached wheel"