PYTHON-5210 Prevent overriding the python used by other tools (#2203)

This commit is contained in:
Steven Silvester 2025-03-14 06:05:21 -05:00 committed by GitHub
parent e6e8650cc9
commit 72ed1029be
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -137,6 +137,11 @@ def run_command(cmd: str | list[str], **kwargs: Any) -> None:
cmd = " ".join(cmd)
LOGGER.info("Running command '%s'...", cmd)
kwargs.setdefault("check", True)
# Prevent overriding the python used by other tools.
env = kwargs.pop("env", os.environ).copy()
if "UV_PYTHON" in env:
del env["UV_PYTHON"]
kwargs["env"] = env
try:
subprocess.run(shlex.split(cmd), **kwargs) # noqa: PLW1510, S603
except subprocess.CalledProcessError as e: