From 1decc04efe63a83ee29f314984f0bcb85b4e48f0 Mon Sep 17 00:00:00 2001 From: Destrayon Date: Tue, 6 Oct 2026 15:33:34 -0500 Subject: [PATCH] setup: skip a cmake/ninja on PATH that does not run, for the one next to this Python A pip launcher whose Python was removed stays on PATH ('ninja --version' fails) and stopped every build there, though setup had just installed a working copy in .venv. --- setup.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 8a3cb96e..8a3c75ba 100644 --- a/setup.py +++ b/setup.py @@ -1285,10 +1285,15 @@ def find_vcvars(cuda_v=None): def find_tool(name): - """A tool on PATH, or the one pip installed next to this Python (cmake, ninja).""" + """A tool on PATH, or the one pip installed next to this Python (cmake, ninja). A PATH copy that does not run + (a pip launcher whose Python is gone) is skipped for the one next to this Python.""" p = shutil.which(name) if p: - return p + try: + if subprocess.run([p, "--version"], capture_output=True, timeout=30).returncode == 0: + return p + except (OSError, subprocess.SubprocessError): + pass for d in (Path(sys.executable).parent / "Scripts", Path(sys.executable).parent, Path.home() / ".local" / "bin"): c = d / (name + (".exe" if WIN else ""))