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

Use PythonEnvironment API in uv venv #4029

Merged
merged 1 commit into from
Jun 5, 2024
Merged

Use PythonEnvironment API in uv venv #4029

merged 1 commit into from
Jun 5, 2024

Conversation

zanieb
Copy link
Member

@zanieb zanieb commented Jun 4, 2024

There's no reason to be reaching into the lower-level find_interpreter manually here.

@zanieb zanieb added the internal A refactor or improvement that is not user-facing label Jun 4, 2024
@zanieb zanieb marked this pull request as ready for review June 4, 2024 23:34
.into_interpreter();
// Locate the Python interpreter to use in the environment
let interpreter =
PythonEnvironment::find(python_request, SystemPython::Required, preview, cache)
Copy link
Member

Choose a reason for hiding this comment

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

Does uv venv from within a venv still work?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll verify this — probably not. I think the find_default_interpreter branch is actually important here.

Thanks for flagging.

Copy link
Member Author

Choose a reason for hiding this comment

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

I wonder if we can add test coverage for that case too...

Copy link
Member Author

@zanieb zanieb Jun 5, 2024

Choose a reason for hiding this comment

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

So what I have here is actually equivalent to the current code. I think uv venv from an active virtual environment doesn't read the interpreter from the virtual environment; I tried to write a test case and it's not working on main. Should it? Maybe this regressed in #3266 and we missed it because we didn't have test coverage?

Copy link
Member Author

@zanieb zanieb Jun 5, 2024

Choose a reason for hiding this comment

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

Adding test coverage in #4045

Copy link
Member Author

Choose a reason for hiding this comment

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

Discussed in Discord, the behavior that Charlie mentioned was changed in #3266 since we skip interpreters in the PATH that are not virtual environments.

There is no behavior change in this pull request and I think the existing behavior is okay for now since we haven't gotten any reports about the change that was released in 0.2.0.

@zanieb zanieb marked this pull request as draft June 4, 2024 23:41
@zanieb zanieb marked this pull request as ready for review June 5, 2024 16:12
@zanieb zanieb merged commit db3c36d into main Jun 5, 2024
46 checks passed
@zanieb zanieb deleted the zb/venv-python-env branch June 5, 2024 16:49
zanieb added a commit that referenced this pull request Jun 5, 2024
…nvironment (#4073)

Closes #4072

This was an accidental change in
#4029 in which I had updated the
pull request to support virtual environments as requested in review and
forgot to revert it.

Separately, we shouldn't fail if `VIRTUAL_ENV` points to an empty
directory and `SystemPython::Allowed` is used, will address that
separately.
zanieb added a commit that referenced this pull request Jun 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internal A refactor or improvement that is not user-facing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants