mirror of https://github.com/astral-sh/uv
Improve debug log for interpreter requests during project commands (#6120)
While it's slightly more convenient to log this where we were, it was pretty unhelpful e.g. ``` DEBUG Interpreter meets the requested Python: `Python >=3.9` ``` What interpreter are we referring to here?
This commit is contained in:
parent
fb6b3ff410
commit
1311127991
|
|
@ -139,24 +139,6 @@ fn find_environment(
|
|||
PythonEnvironment::from_root(workspace.venv(), cache)
|
||||
}
|
||||
|
||||
/// Check if the given interpreter satisfies the project's requirements.
|
||||
fn interpreter_meets_requirements(
|
||||
interpreter: &Interpreter,
|
||||
requested_python: Option<&PythonRequest>,
|
||||
cache: &Cache,
|
||||
) -> bool {
|
||||
let Some(request) = requested_python else {
|
||||
return true;
|
||||
};
|
||||
if request.satisfied(interpreter, cache) {
|
||||
debug!("Interpreter meets the requested Python: `{request}`");
|
||||
true
|
||||
} else {
|
||||
debug!("Interpreter does not meet the request: `{request}`");
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub(crate) enum FoundInterpreter {
|
||||
|
|
@ -226,17 +208,23 @@ impl FoundInterpreter {
|
|||
// Read from the virtual environment first.
|
||||
match find_environment(workspace, cache) {
|
||||
Ok(venv) => {
|
||||
if interpreter_meets_requirements(
|
||||
venv.interpreter(),
|
||||
python_request.as_ref(),
|
||||
cache,
|
||||
) {
|
||||
if python_request.as_ref().map_or(true, |request| {
|
||||
if request.satisfied(venv.interpreter(), cache) {
|
||||
debug!("The virtual environment's Python version satisfies `{request}`");
|
||||
true
|
||||
} else {
|
||||
debug!(
|
||||
"The virtual environment's Python version does not satisfy `{request}`"
|
||||
);
|
||||
false
|
||||
}
|
||||
}) {
|
||||
if let Some(requires_python) = requires_python.as_ref() {
|
||||
if requires_python.contains(venv.interpreter().python_version()) {
|
||||
return Ok(Self::Environment(venv));
|
||||
}
|
||||
debug!(
|
||||
"Interpreter does not meet the project's Python requirement: `{requires_python}`"
|
||||
"The virtual environment's Python version does not meet the project's Python requirement: `{requires_python}`"
|
||||
);
|
||||
} else {
|
||||
return Ok(Self::Environment(venv));
|
||||
|
|
|
|||
Loading…
Reference in New Issue