Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Omit interpreter path during uv venv with managed Python #5311

Merged
merged 1 commit into from
Jul 23, 2024

Conversation

zanieb
Copy link
Member

@zanieb zanieb commented Jul 22, 2024

e.g.

❯ cargo run -q -- venv --preview
Using Python 3.12.1
Creating virtualenv at: .venv
Activate with: source .venv/bin/activate

instead of

❯ cargo run -q -- venv --preview
Using Python 3.12.1 interpreter at: /Users/zb/Library/Application Support/uv/python/cpython-3.12.1-macos-aarch64-none/bin/python3
Creating virtualenv at: .venv
Activate with: source .venv/bin/activate

@zanieb zanieb added cli Related to the command line interface preview Experimental behavior labels Jul 22, 2024
@zanieb
Copy link
Member Author

zanieb commented Jul 22, 2024

I went back and forth on saying "Using managed Python XXX" but am leaning no.

There will be follow-ups to do this elsewhere.

.into_interpreter();
.into_diagnostic()?;

let managed = python.source().is_managed();
Copy link
Member Author

@zanieb zanieb Jul 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively we could check if this is a child of the managed Python directory but that seems more brittle.

@zanieb
Copy link
Member Author

zanieb commented Jul 22, 2024

I think there should be no test changes here since we find all the interpreters on the PATH during tests — if a managed interpreter is found on the PATH instead of via a managed Python directory scan we'll still show the path as before.

@zanieb zanieb marked this pull request as ready for review July 23, 2024 16:51
Copy link
Member

@BurntSushi BurntSushi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At first I was sad that the path to the interpreter was going away, but then I realized that it was only going away in the case of managed Python (which, of course, you said, but it didn't register for me). And then I was happy again.

I like this!

@zanieb
Copy link
Member Author

zanieb commented Jul 23, 2024

:) I could have included that in the pull request body too — a little lazy of me.

Here's the verbose output fwiw:

❯ cargo run -q -- venv -v --preview
DEBUG uv 0.2.27
DEBUG Reading requests from `.python-versions`
DEBUG Using the first version from `.python-versions`
DEBUG Searching for Python 3.12.1 in managed installations or system path
DEBUG Searching for managed installations at `/Users/zb/Library/Application Support/uv/python`
DEBUG Found managed Python `cpython-3.12.1-macos-aarch64-none`
DEBUG Found cpython 3.12.1 at `/Users/zb/Library/Application Support/uv/python/cpython-3.12.1-macos-aarch64-none/bin/python3` (managed installations)
Using Python 3.12.1
Creating virtualenv at: .venv
INFO Removing existing directory
Activate with: source .venv/bin/activate

@BurntSushi
Copy link
Member

That's awesome. (I have so many ancient scars from using a different python than I thought I was using.)

@zanieb zanieb merged commit 6fe9bd8 into main Jul 23, 2024
54 checks passed
@zanieb zanieb deleted the zb/venv-managed branch July 23, 2024 19:20
zanieb added a commit that referenced this pull request Jul 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli Related to the command line interface preview Experimental behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants