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 ""))