From b317e6fc56d3f03d0a68a45784aac8936c2fbc9a Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Sun, 18 Feb 2024 15:22:39 -0600 Subject: [PATCH] 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. --- python/uv/__main__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/uv/__main__.py b/python/uv/__main__.py index 975a72941..0d57b35b1 100644 --- a/python/uv/__main__.py +++ b/python/uv/__main__.py @@ -50,10 +50,10 @@ def find_uv_bin() -> str: if __name__ == "__main__": uv = os.fsdecode(find_uv_bin()) - env = {} + env = os.environ.copy() venv = detect_virtualenv() if venv: - env["VIRTUAL_ENV"] = venv + env.setdefault("VIRTUAL_ENV", venv) if sys.platform == "win32": import subprocess