mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-11-16 19:04:08 +03:00
0f2ee4d80f
Setup asked for just by name: `pm install --test-environment` and every setup-pm toolchain. A lockfile without a just pin (an older branch, a test fixture repo) then stopped setup with "just: not in the lockfile", and archive_inputs refused it as an unknown pinned package. Both paths now take the developer tools from the lockfile they read, so a lockfile without just installs without it. The repository lock pins just, so developers and CI still get it.
53 lines
2.1 KiB
Python
53 lines
2.1 KiB
Python
"""The isolated environment a checkout's test suite runs under.
|
|
|
|
Activation builds it beside the checkout's install state, and CI builds it the
|
|
same way. It carries the locked project dependencies plus the ``dev`` and
|
|
``test`` groups. It is a side environment
|
|
(``ensure_project_environment``), never the selected application generation:
|
|
test-only dependencies must not enter PM facts or anything that ships.
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
from collections.abc import Sequence
|
|
from pathlib import Path
|
|
|
|
from pm.environments import install_state_dir
|
|
|
|
NAME = "test-environment"
|
|
# The default developer environment includes the app's normal features.
|
|
# CI lanes pass their wider provider matrix explicitly.
|
|
DEFAULT_TEST_EXTRAS = ("all",)
|
|
GROUPS = ("dev", "test")
|
|
# Optional pm packages a checkout's developers run; user installs never request them.
|
|
DEVELOPER_TOOLS = ("just",)
|
|
|
|
|
|
def developer_tools(pinned: Sequence[str]) -> list[str]:
|
|
"""The developer tools this lockfile pins; an older lockfile without one still installs."""
|
|
return [name for name in DEVELOPER_TOOLS if name in pinned]
|
|
|
|
|
|
def testenv_root(project_root: Path) -> Path:
|
|
return install_state_dir(project_root) / NAME
|
|
|
|
|
|
def ensure_testenv(project_root: Path, extras: Sequence[str] | None = None) -> Path:
|
|
"""Build the test environment unless its locked inputs are unchanged; return its python."""
|
|
from pm import ensure_project_environment
|
|
|
|
chosen = sorted(set(DEFAULT_TEST_EXTRAS if extras is None else extras))
|
|
return ensure_project_environment(NAME, project_root, extras=chosen, groups=GROUPS,
|
|
root=testenv_root(project_root), explicit=True)
|
|
|
|
|
|
def testenv_python(project_root: Path) -> Path | None:
|
|
"""The selected test interpreter, read without acquiring tools or writing state."""
|
|
from pm.operations import environment_python
|
|
|
|
return environment_python(NAME, root=testenv_root(project_root))
|
|
|
|
|
|
def parse_extras(value: str) -> list[str] | None:
|
|
"""An empty value selects default extras; commas and spaces separate overrides."""
|
|
return value.replace(",", " ").split() or None
|