Interpreter for ``pip``/``-m swebench``/``uvicorn`` subprocesses. When ``SWEBENCH_PYTHON`` (or the given *env_var*) is unset, we use :data:`sys.executable` — the same Python that is running *this* script — so a venv-local ``uv pip install -e ./SWE-bench-dev`` is visible to ``prepare``.
(env_var: str, fallback: str = "python3")
| 206 | |
| 207 | |
| 208 | def _resolve_python(env_var: str, fallback: str = "python3") -> str: |
| 209 | """Interpreter for ``pip``/``-m swebench``/``uvicorn`` subprocesses. |
| 210 | |
| 211 | When ``SWEBENCH_PYTHON`` (or the given *env_var*) is unset, we use |
| 212 | :data:`sys.executable` — the same Python that is running *this* script — so |
| 213 | a venv-local ``uv pip install -e ./SWE-bench-dev`` is visible to ``prepare``. |
| 214 | |
| 215 | On Windows, ``shutil.which("python3")`` often resolves to the Microsoft Store |
| 216 | stub under ``WindowsApps``, which does not see your project venv; avoiding |
| 217 | that shims the common ``.venv/Scripts/python.exe eval/run_compare.py`` flow. |
| 218 | """ |
| 219 | explicit = os.environ.get(env_var) |
| 220 | if explicit: |
| 221 | return explicit |
| 222 | exe = sys.executable |
| 223 | if exe and Path(exe).exists(): |
| 224 | return exe |
| 225 | for name in (fallback, "python"): |
| 226 | found = shutil.which(name) |
| 227 | if found and "windowsapps" not in found.lower(): |
| 228 | return found |
| 229 | raise SystemExit( |
| 230 | f"Could not locate a Python interpreter ({env_var} or '{fallback}'). " |
| 231 | f"Run with your project venv, e.g. `.venv/Scripts/python.exe eval/run_compare.py ...`, " |
| 232 | f"or set {env_var} to that interpreter." |
| 233 | ) |
| 234 | |
| 235 | |
| 236 | def _http_get(url: str, timeout: float) -> tuple[int, bytes]: |
no test coverage detected