From 5c1a304ce890276a4334d8ced3f29ffeedbbbf93 Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Sun, 23 Aug 2026 02:07:18 -0700 Subject: [PATCH] fix: derive the pinned interpreter's Scripts dir via venv_bin_dir (#76105 lint) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The salvaged _interpreter_scripts_dir hand-rolled the Scripts/bin layout, which the AST lint-test in test_update_zip_two_phase forbids — route it through the canonical hermes_constants.venv_bin_dir instead, with the interpreter's own dir as fallback for non-venv layouts. --- hermes_cli/main.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/hermes_cli/main.py b/hermes_cli/main.py index 6ebaf4cf31..7f4c0e9a40 100644 --- a/hermes_cli/main.py +++ b/hermes_cli/main.py @@ -9606,16 +9606,18 @@ def _interpreter_scripts_dir() -> Path | None: Used when pinning an install to ``sys.executable`` on a site-packages install where ``PROJECT_ROOT / "venv"`` does not exist: the entry-point shims uv rewrites live next to the interpreter, not under a project venv. + Layout comes from the canonical ``venv_bin_dir`` helper (#76105 — + hand-rolling Scripts/bin is lint-tested against). """ + from hermes_constants import venv_bin_dir + exe = Path(sys.executable) - parent = exe.parent - scripts_candidates = ( - [parent / "Scripts"] if _is_windows() else [parent / "bin"] - ) - for cand in scripts_candidates: - if cand.is_dir(): - return cand - return None + # sys.executable lives IN the bin/Scripts dir; its parent.parent is the + # env root venv_bin_dir derives from. + cand = venv_bin_dir(exe.parent.parent, windows=_is_windows()) + if cand.is_dir(): + return cand + return exe.parent if exe.parent.is_dir() else None def _install_python_dependencies_with_optional_fallback(