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

Allow --python <dir> requests to match existing environments if sys.executable is the same file #11290

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

zanieb
Copy link
Member

@zanieb zanieb commented Feb 6, 2025

Closes #11288

I tested the reproduction there manually.

I'm a little uncertain about this behavior, it's not true to the spirit of --python <dir> selecting a target environment but this method is only used to see if an existing environment matches for the purpose of invalidation in projects and tools where I think we always force a separate environment anyway?

@zanieb zanieb added the bug Something isn't working label Feb 6, 2025
@@ -1476,8 +1476,12 @@ impl PythonRequest {
version_request.matches_interpreter(interpreter)
}
PythonRequest::Directory(directory) => {
// `sys.prefix` points to the venv root.
// `sys.prefix` points to the environment root or `sys.executable` is the same
is_same_executable(directory, interpreter.sys_prefix())
Copy link
Member Author

Choose a reason for hiding this comment

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

Arguably, we could remove this first check. Mildly afraid of something breaking though.

@zanieb zanieb marked this pull request as ready for review February 9, 2025 18:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

uv run --python <path> <tool> always recreates virtualenvironment
2 participants