The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): Windows native wheels and vcpkg OpenSSL reuse the restored cache
ethernete97ce2a45787
diff --git a/scripts/bundles/desktop_toolchain.py b/scripts/bundles/desktop_toolchain.pyindex 98d08f62b5c..40a87558a75 100644--- a/scripts/bundles/desktop_toolchain.py+++ b/scripts/bundles/desktop_toolchain.py@@ -51,6 +51,9 @@ def bootstrap_environment(source: Path, work: Path, cache: Path,"XDG_CONFIG_HOME": str(home / "config"), "XDG_CACHE_HOME": str(home / "cache"),"XDG_DATA_HOME": str(home / "data"), "XDG_STATE_HOME": str(home / "state"),"UV_CACHE_DIR": str(cache / "python/runtime"),+ # vcpkg's default binary cache is under LOCALAPPDATA, which moved into the+ # job-local home above; keep its archives in the transported native domain.+ "VCPKG_DEFAULT_BINARY_CACHE": str(cache / "native/vcpkg-archives"),"npm_config_cache": str(cache / "npm"),"npm_config_userconfig": os.devnull,"PYTHONUTF8": "1", "PYTHONDONTWRITEBYTECODE": "1",@@ -122,6 +125,23 @@ def prepare_tools(source: Path, work: Path, cache: Path,return binaries["python"], binaries["node"], prepared+def _msvc_identity() -> dict[str, str] | None:+ """The newest VC toolset vswhere reports, with its default tools version."""+ vswhere = Path(os.environ.get("ProgramFiles(x86)", r"C:\Program Files (x86)"),+ "Microsoft Visual Studio/Installer/vswhere.exe")+ try:+ result = subprocess.run([str(vswhere), "-latest", "-products", "*", "-requires",+ "Microsoft.VisualStudio.Component.VC.Tools.x86.x64", "-format", "json"],+ capture_output=True, text=True, encoding="utf-8", errors="replace",+ timeout=30, stdin=subprocess.DEVNULL, check=False)+ instance = json.loads(result.stdout or "[]")[0]+ tools = Path(instance["installationPath"], "VC/Auxiliary/Build/Microsoft.VCToolsVersion.default.txt")+ return {"installationVersion": instance["installationVersion"],+ "VCToolsVersion": tools.read_text(encoding="utf-8").strip()}+ except (OSError, subprocess.TimeoutExpired, ValueError, IndexError, KeyError):+ return None++def native_cache_path(cache: Path, env: Mapping[str, str]) -> Path:"""Partition built wheels by observed native inputs, not just the OS label.@@ -140,8 +160,15 @@ def native_cache_path(cache: Path, env: Mapping[str, str]) -> Path:"libc": platform.libc_ver(), "inputs": selected, "probes": [], "openssl": {}}commands = [["rustc", "-vV"]]if target.startswith("win32"):- commands.append(["cl", "/Bv"])- complete = bool(env.get("WindowsSDKVersion") and env.get("VCToolsVersion"))+ if env.get("VCToolsVersion"):+ commands.append(["cl", "/Bv"])+ complete = bool(env.get("WindowsSDKVersion"))+ else:+ # No developer environment (win32-x64 builds never run VsDevCmd): rustc's cc+ # crate finds MSVC through vswhere, so identify the toolchain the same way.+ msvc = _msvc_identity()+ identity["msvc"] = msvc+ complete = msvc is not Noneelse:commands.extend([[env.get("CC") or "cc", "--version"], [env.get("CXX") or "c++", "--version"]])complete = Truediff --git a/scripts/windows-build-deps.ps1 b/scripts/windows-build-deps.ps1index 779342b36b2..b328a7e1e8d 100644--- a/scripts/windows-build-deps.ps1+++ b/scripts/windows-build-deps.ps1@@ -72,6 +72,8 @@ function Install-HermesArm64OpenSSL {$required = @('include\openssl\ssl.h', 'lib\libcrypto.lib', 'lib\libssl.lib')$missing = @($required | Where-Object { -not (Test-Path -LiteralPath (Join-Path $prefix $_) -PathType Leaf) })if ($missing.Count) {+ # vcpkg refuses a binary cache directory that does not exist yet.+ if ($env:VCPKG_DEFAULT_BINARY_CACHE) { New-Item -ItemType Directory -Force -Path $env:VCPKG_DEFAULT_BINARY_CACHE | Out-Null }Invoke-HermesBuildCommand $Vcpkg @('install', 'openssl:arm64-windows-static-md', '--classic', '--disable-metrics', "--x-install-root=$(Join-Path $Root 'installed')") 'Building static ARM64 OpenSSL via vcpkg (several minutes)'} else {Write-HermesBuildNote "ARM64 OpenSSL development libraries found: $prefix"diff --git a/tests/scripts/test_desktop_toolchain.py b/tests/scripts/test_desktop_toolchain.pyindex 0132d7d0a0c..ed683acb85f 100644--- a/tests/scripts/test_desktop_toolchain.py+++ b/tests/scripts/test_desktop_toolchain.py@@ -295,3 +295,28 @@ def test_native_cache_leaves_room_for_sdist_compiler_outputs(tmp_path, monkeypat/ 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)++[email protected]("windows")+def test_native_cache_is_stable_without_a_developer_environment(tmp_path, monkeypatch):+ """win32-x64 never runs VsDevCmd, so VCToolsVersion is unset there. Its built+ wheels must still land in one partition per toolchain, not a fresh one per run."""+ from scripts.bundles import desktop_toolchain++ install = tmp_path / "vs"+ version_file = install / "VC/Auxiliary/Build/Microsoft.VCToolsVersion.default.txt"+ version_file.parent.mkdir(parents=True)+ version_file.write_text("14.44.35207\n", encoding="utf-8")+ vswhere = json.dumps([{"installationPath": str(install), "installationVersion": "17.14.1"}])++ def probe(command, **kwargs):+ stdout = vswhere if command[0].endswith("vswhere.exe") else "rustc 1.98.0"+ return SimpleNamespace(returncode=0, stdout=stdout, stderr="")++ desktop_toolchain.platform.platform()+ monkeypatch.setattr(desktop_toolchain.subprocess, "run", probe)+ cache, env = tmp_path / "cache", {"PATH": os.defpath}+ first = desktop_toolchain.native_cache_path(cache, env)+ assert desktop_toolchain.native_cache_path(cache, env) == first+ version_file.write_text("14.45.0\n", encoding="utf-8")+ assert desktop_toolchain.native_cache_path(cache, env) != first