From a07438f52f813babcd7d8e88e01d35d995df2b98 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Sun, 17 Mar 2024 19:57:36 -0700 Subject: [PATCH] Re-add support for pyenv shims (#2503) ## Summary By running `get_interpreter_info.py` outside of the current working directory, we seem to have broken pyenv shims. Closes https://github.com/astral-sh/uv/issues/2488. ## Test Plan Without this change (resolving to the Homebrew Python, even though we start with a shim): ``` DEBUG Starting interpreter discovery for Python @ `python3.11` DEBUG Probing interpreter info for: /Users/crmarsh/.pyenv/shims/python3.11 DEBUG Found Python 3.11.7 for: /Users/crmarsh/.pyenv/shims/python3.11 Using Python 3.11.7 interpreter at: /opt/homebrew/opt/python@3.11/bin/python3.11 Creating virtualenv at: .venv INFO Removing existing directory Activate with: source .venv/bin/activate ``` With this change: ``` DEBUG Starting interpreter discovery for Python @ `python3.11` DEBUG Probing interpreter info for: /Users/crmarsh/.pyenv/shims/python3.11 DEBUG Found Python 3.11.1 for: /Users/crmarsh/.pyenv/shims/python3.11 Using Python 3.11.1 interpreter at: /Users/crmarsh/.pyenv/versions/3.11.1/bin/python3.11 Creating virtualenv at: .venv INFO Removing existing directory Activate with: source .venv/bin/activate ``` --- crates/uv-interpreter/src/interpreter.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/uv-interpreter/src/interpreter.rs b/crates/uv-interpreter/src/interpreter.rs index 896f547ec..660ec190e 100644 --- a/crates/uv-interpreter/src/interpreter.rs +++ b/crates/uv-interpreter/src/interpreter.rs @@ -372,7 +372,8 @@ impl InterpreterInfo { let output = Command::new(interpreter) .arg("-m") .arg("python.get_interpreter_info") - .current_dir(tempdir.path().simplified()) + .env("PYTHONPATH", tempdir.path()) + .env("PYTHONSAFEPATH", "1") .output() .map_err(|err| Error::PythonSubcommandLaunch { interpreter: interpreter.to_path_buf(),