Files
hermes-agent/tests/installation_launcher_fixture.py
ethernet bbec973514 refactor(pm): pm owns the dependency-environment layout and interpreter paths
hermes_cli.runtime_paths (venv generations, selection, activation) moves to
pm.environments, and gains venv_bin_dir / venv_python / project_python. Every
in-tree caller asks pm for an interpreter now; pm no longer reaches back into
hermes_cli for its own environment layout (pm.packages, pm.extras, pm.ensure,
pm.paths imported hermes_cli.runtime_paths). The three open-coded
"Scripts/python.exe or bin/python" ladders in pm collapse onto venv_python.

hermes_constants.venv_python_path / venv_bin_dir and hermes_cli.runtime_paths
stay as frozen-updater-surface shims only (tests/compat/old_updater_surface.json).

To keep the boot path light, pm/__init__ resolves its facade lazily (PEP 562)
and pm.registry loads the built-in package definitions on first read instead of
at import: `import hermes_bootstrap` now loads pm + pm.environments only (25ms,
was 37ms with the eager facade dragging in the downloader). The stripped-payload
fixtures that ship only pre-import files keep working for the same reason.

Also restores two frozen-surface re-exports the F401 sweep dropped
(banner._github_compare_behind, cua_backend.resolve_cua_driver_cmd).
2026-09-18 20:02:36 -04:00

27 lines
1.1 KiB
Python

"""A real published launcher driving a disposable CLI, without installing deps."""
from pathlib import Path
import shutil
import sys
from hermes_cli._launchers import mint_launcher
def publish_fixture_launcher(root: Path, main_source: str) -> Path:
repository = Path(__file__).resolve().parents[1]
package = root / "hermes_cli"
package.mkdir(parents=True, exist_ok=True)
(package / "__init__.py").touch()
(package / "main.py").write_text(main_source, encoding="utf-8")
# The application is a stand-in; launcher production and command queries
# are real. The interpreter is external to the checkout, like PM's store.
(root / "hermes_bootstrap.py").write_text("", encoding="utf-8")
(root / "pm").mkdir(exist_ok=True)
for relative in ("hermes_constants.py", "hermes_cli/_launchers.py", "pm/environments.py"):
shutil.copyfile(repository / relative, root / relative)
out = root / ".hermes" / "bin"
out.mkdir(parents=True)
launcher = mint_launcher("hermes", root, out, Path(sys.executable), None)
assert launcher is not None
assert not (root / "venv").exists()
return launcher