Files
hermes-agent/scripts/build/icon_environment.py
ethernet 2efa4ff94f refactor(desktop): prepare dependencies before saving build caches
Dependency acquisition during packaging left native wheels and packager
inputs outside the pre-build cache save. Compose PM and existing providers
into a preparation phase, then require builds to consume admitted inputs.

Share native preparation with PM Bundle. Keep path-bound environments and
signing outputs separate from reusable caches. Use read-only cache tokens
for commit builds and preserve the one-command local build path.

Verify pinned tools through PM, probe PTYs under the prepared Electron,
and supply dmgbuild through a build-only PM package. Resolve bundled tool
stores from their payload manifest so relocation preserves discovery.

Validation: focused Python and JS tests, checkJs, Ruff, Windows checks,
anti-slop, cache relocation, and network-denied Linux AppImage builds.
Relocated runtime smoke passed with NixOS host libraries supplied.
Native Windows/macOS signing and live GitHub cache behavior remain untested.
2026-09-13 14:28:31 -04:00

47 lines
1.6 KiB
Python

"""Prepare the locked icon-only environment through PM, then run the generator."""
from __future__ import annotations
import argparse
from pathlib import Path
import subprocess
import sys
from tempfile import TemporaryDirectory
# The Node wrapper can run this file from a separately prepared source tree.
ROOT = Path(__file__).resolve().parents[2]
sys.path.insert(0, str(ROOT))
import pm
def prepare_icon_environment(source: Path, out: Path, cache: Path, *, explicit: bool = True) -> Path:
"""Prepare a fresh locked build-only interpreter without generating assets."""
return pm.build_environment(
source=source.resolve(), out=out.resolve(), cache=cache.resolve(),
groups=["icon-build"], only_groups=True, explicit=explicit,
)
def main(argv: list[str] | None = None) -> int:
argv = list(sys.argv[1:] if argv is None else argv)
parser = argparse.ArgumentParser(add_help=False, allow_abbrev=False)
parser.add_argument("--source", type=Path, default=ROOT)
parser.add_argument("--on-demand", action="store_true")
args, _ = parser.parse_known_args(argv)
if args.on_demand:
argv.remove("--on-demand")
source = args.source.resolve()
with TemporaryDirectory(prefix="hermes-icon-build-") as temporary:
python = prepare_icon_environment(
source, Path(temporary) / "venv", source / ".cache/icon-build",
explicit=not args.on_demand,
)
return subprocess.run(
[str(python), "-I", str(ROOT / "scripts/generate_icons.py"), *argv],
cwd=source,
).returncode
if __name__ == "__main__":
raise SystemExit(main())