MCPcopy Create free account
hub / github.com/agentforce314/clawcodex / _resolve_python

Function _resolve_python

eval/run_compare.py:208–233  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

206
207
208def _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
236def _http_get(url: str, timeout: float) -> tuple[int, bytes]:

Callers 2

cmd_prepareFunction · 0.85
cmd_runFunction · 0.85

Calls 1

getMethod · 0.45

Tested by

no test coverage detected