Files
hermes-agent/scripts/build/windows_deps.py
ethernet fea2858c99 merge: unify shared product builders, caches, and Windows prerequisites
Merge ethie/shared-product-builders with the CI dependency cache and native Windows setup work. Preserve UTF-8 diagnostics in the shared Python environment runner. Pass a persistent cache through isolated native staging and PM-runtime construction. Reuse one Windows prerequisite installer from source setup, native adapters, and CI, preserving Rust homes across HOME isolation.

Verified 85 targeted Python tests (5 host skips), 18 JavaScript tests, workflow validation, and scoped lint/typecheck. On native Windows ARM64, five prerequisite contracts passed and the actual shared provider reused OpenSSL, compiled its header with MSVC, and retained Rust under isolated HOME. Full signed distribution builds and live Actions cache transfer remain CI verification.
2026-09-11 13:45:05 -04:00

30 lines
1.4 KiB
Python

"""Prepare native Windows build inputs without changing the caller's process."""
from __future__ import annotations
from collections.abc import Mapping
import json
from pathlib import Path
import shutil
import subprocess
import tempfile
def prepare_windows_environment(*, source: Path, state: Path, env: Mapping[str, str]) -> dict[str, str]:
"""The distribution adapter decides whether this target needs ARM64 tools."""
shell = shutil.which("powershell", path=env.get("PATH")) or shutil.which("pwsh", path=env.get("PATH"))
if shell is None:
raise FileNotFoundError("PowerShell is required to prepare Windows ARM64 build dependencies")
state.mkdir(parents=True, exist_ok=True)
with tempfile.TemporaryDirectory(prefix="environment-", dir=state) as scratch:
output = Path(scratch) / "environment.json"
subprocess.run(
[shell, "-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass", "-File",
str(source / "scripts/build/windows-deps.ps1"), "-StateRoot", str(state),
"-EnvironmentFile", str(output)],
cwd=source, env=dict(env), check=True,
)
prepared = json.loads(output.read_text(encoding="utf-8-sig"))
if not isinstance(prepared, dict) or any(not isinstance(k, str) or not isinstance(v, str) for k, v in prepared.items()):
raise ValueError("Windows build dependency provider returned an invalid environment")
return prepared