-
Notifications
You must be signed in to change notification settings - Fork 790
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
Enable freeze
and list
to introspect non-virtualenv Pythons
#2033
Conversation
freeze
and list
to enumerate default Python installsfreeze
and list
to introspect non-virtualenv Pythons
match Virtualenv::from_env(platform.clone(), cache) { | ||
Ok(venv) => venv, | ||
Err(uv_interpreter::Error::VenvNotFound) => { | ||
Virtualenv::from_default_python(&platform, cache)? |
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.
This does mean that if a virtualenv doesn't exist, we "silently" fall back to the default Python; and you'll never see the "No virtualenv exists" error, only the error you might get if the fallback fails.
It kind of makes me want to change this to user-facing logging?
debug!(
"Using Python {} environment at {}",
venv.interpreter().python_version(),
venv.python_executable().normalized_display().cyan()
);
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.
👍
match Virtualenv::from_env(platform.clone(), cache) { | ||
Ok(venv) => venv, | ||
Err(uv_interpreter::Error::VenvNotFound) => { | ||
Virtualenv::from_default_python(&platform, cache)? |
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.
👍
crates/uv/src/main.rs
Outdated
/// The Python interpreter for which packages should be listed. | ||
/// | ||
/// By default, `uv` lists packages in the currently activated virtual environment, or an | ||
/// environment located in the current working directory or any parent directory, falling back |
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.
/// environment located in the current working directory or any parent directory, falling back | |
/// environment `.venv` located in the current working directory or any parent directory, falling back |
/// | ||
/// Supported formats: | ||
/// - `3.10` looks for an installed Python 3.10 using `py --list-paths` on Windows, or | ||
/// `python3.10` on Linux and macOS. (Specifying a patch version is not supported.) |
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.
Patch versions are supported
9109caf
to
ce52146
Compare
Summary
Now that we have the ability to introspect the installed packages for arbitrary Pythons, we can allow
pip freeze
andpip list
to fall back to the "default" Python, if no virtualenv is present.Closes #2005.