-
Notifications
You must be signed in to change notification settings - Fork 662
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
Detect current venv when uv
is invoked from within a virtualenv
#3379
Conversation
Thanks, this looks reasonable to me. |
uv
is invoked from within a virtualenv
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still have questions...
/// Finds a `.venv` directory in the current or any parent directory. | ||
/// Checks if the working directory is a virtual environment. | ||
/// | ||
/// If not, finds a `.venv` directory in the current or any parent directory. | ||
pub(crate) fn virtualenv_from_working_dir() -> Result<Option<PathBuf>, Error> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for merging !
The comment is not in line with the strategy.
Should I make a PR or let you fix it ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if dir.join("pyvenv.cfg").is_file() { | ||
debug!("Found a virtualenv at: {}", dir.display()); | ||
return Ok(Some(dir.to_path_buf())); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the reasoning behind moving the check for pyvenv.cfg
before search for .venv
to after the search ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main thing I wanted to change here was looking in ancestor directories, so that if you're in .venv/bin
, we still find the current venv. Whether this check comes before or after the // Search for a
.venv directory.
step is somewhat less clear, that's a weird situation (you have a nested venv within a venv).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixes #3378
Does this still demands a test ?