mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-11-06 13:26:40 +00:00
The shell pointed HERMES_PYTHON at the bare pm-pinned interpreter and reached the uv2nix site-packages only through PYTHONPATH. Every consumer that replaces PYTHONPATH (Ink's gateway bootstrap, image attachments, run_tests.sh's env -i) got an interpreter with no dependencies, so 'hermes --tui' in the shell failed with 'No module named ruamel'. devVenv re-homes uv2nix's editable venv onto the pinned interpreter: a real pyvenv.cfg whose home is the lock's python, devPython's site-packages, and console scripts re-shebanged onto it. HERMES_PYTHON, VIRTUAL_ENV, python, pytest and pm are now one interpreter and the shell sets no PYTHONPATH. The shipped package and the shell share one tool list: runtimeDeps takes ripgrep and ffmpeg from pm/lock.json too. Reverts the run_tests.sh PYTHONPATH passthrough, which leaked a caller's PYTHONPATH into every HERMES_PYTHON run. The dev-venv-self-contained check runs the venv under env -i.
41 lines
1.2 KiB
Nix
41 lines
1.2 KiB
Nix
# Nix uses the Python family pinned by PM, not a second version constant.
|
|
{
|
|
lib,
|
|
pkgs,
|
|
}:
|
|
let
|
|
pythonFamily =
|
|
lockfile:
|
|
let
|
|
version = (builtins.fromJSON (builtins.readFile lockfile)).packages.python.version;
|
|
parts = builtins.match "([0-9]+)\\.([0-9]+)(\\..*)?" version;
|
|
in
|
|
if parts == null then
|
|
throw "packages.python.version '${version}' is not a Python <major>.<minor> version — cannot derive the Nix interpreter from it"
|
|
else
|
|
builtins.elemAt parts 0 + "." + builtins.elemAt parts 1;
|
|
|
|
# Select pkgs.python3NN by family ("3.14" -> pkgs.python314). A missing
|
|
# lookup throws; there is no default interpreter to fall back to.
|
|
selectPython =
|
|
family: packageSet:
|
|
let
|
|
name = "python" + lib.replaceStrings [ "." ] [ "" ] family;
|
|
interp = packageSet.${name} or null;
|
|
in
|
|
if interp == null then
|
|
throw "package set does not provide ${name}, but pm/lock.json pins Python ${family} — update the nixpkgs input; Nix will not silently substitute another Python"
|
|
else
|
|
interp;
|
|
|
|
lockfile = ../pm/lock.json;
|
|
family = pythonFamily lockfile;
|
|
in
|
|
{
|
|
inherit pythonFamily selectPython;
|
|
|
|
inherit family;
|
|
|
|
interpreter = selectPython family pkgs;
|
|
}
|