Ensure we retain existing environment variables during `python -m uv` (#1667)

From https://github.com/astral-sh/uv/issues/1623#issuecomment-1951368507

I thought I checked this was working correctly in #1504 but I guess the
environment is not preserved like I thought.
This commit is contained in:
Zanie Blue 2024-02-18 15:22:39 -06:00 committed by GitHub
parent 3ed386c0c5
commit b317e6fc56
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 2 deletions

View File

@ -50,10 +50,10 @@ def find_uv_bin() -> str:
if __name__ == "__main__": if __name__ == "__main__":
uv = os.fsdecode(find_uv_bin()) uv = os.fsdecode(find_uv_bin())
env = {} env = os.environ.copy()
venv = detect_virtualenv() venv = detect_virtualenv()
if venv: if venv:
env["VIRTUAL_ENV"] = venv env.setdefault("VIRTUAL_ENV", venv)
if sys.platform == "win32": if sys.platform == "win32":
import subprocess import subprocess