From 9010491bfd1ed9d93086dac8d673a2346de41a06 Mon Sep 17 00:00:00 2001 From: Mark Janzer Date: Mon, 13 Apr 2026 11:36:05 -0700 Subject: [PATCH] fix: prefer unresolved sys.executable to stay inside venv On macOS with Homebrew Python, `Path(sys.executable).resolve()` follows the venv symlink back to the system interpreter. PEP 668 then blocks pip installs with "externally-managed-environment", causing the setup tour to fail. Swap the check order so the unresolved venv path is preferred when it exists, falling back to the resolved path only when necessary. Co-Authored-By: Claude Opus 4.6 --- scripts/start_tour.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/start_tour.py b/scripts/start_tour.py index f9d6eee71..cbe930bdb 100644 --- a/scripts/start_tour.py +++ b/scripts/start_tour.py @@ -28,11 +28,14 @@ def _resolve_python() -> str: """ exe = sys.executable if exe: + # Prefer the unresolved path first — resolving symlinks can escape + # a virtual-env and point at the system Python, which on modern + # Homebrew / PEP 668 installs will refuse ``pip install``. + if Path(exe).exists(): + return exe resolved = str(Path(exe).resolve()) if Path(resolved).exists(): return resolved - if Path(exe).exists(): - return exe for name in ("python3", "python"): found = shutil.which(name) if found: