Skip to content

Commit

Permalink
Re-add support for pyenv shims (#2503)
Browse files Browse the repository at this point in the history
## Summary

By running `get_interpreter_info.py` outside of the current working
directory, we seem to have broken pyenv shims.

Closes #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
```
  • Loading branch information
charliermarsh authored Mar 18, 2024
1 parent 653327b commit a07438f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion crates/uv-interpreter/src/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down

0 comments on commit a07438f

Please sign in to comment.