Skip to content

Commit 1883998

Browse files
committed
Add debug logs
1 parent 7978ad9 commit 1883998

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

crates/uv-python/src/discovery.rs

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -679,20 +679,45 @@ pub fn satisfies_python_preference(
679679
) -> bool {
680680
match preference {
681681
PythonPreference::OnlyManaged => {
682-
matches!(source, PythonSource::Managed) || interpreter.is_managed()
682+
// Perform a fast check using the source before querying the interpreter
683+
if matches!(source, PythonSource::Managed) || interpreter.is_managed() {
684+
true
685+
} else {
686+
debug!(
687+
"Ignoring Python interpreter at `{}`: only managed interpreters allowed",
688+
interpreter.sys_executable().display()
689+
);
690+
false
691+
}
683692
}
684693
// If not "only" a kind, any interpreter is okay
685694
PythonPreference::Managed | PythonPreference::System => true,
686695
PythonPreference::OnlySystem => match source {
687696
// A managed interpreter is never a system interpreter
688-
PythonSource::Managed => false,
697+
PythonSource::Managed => {
698+
debug!(
699+
"Ignoring Python interpreter at `{}`: only unmanaged interpreters allowed",
700+
interpreter.sys_executable().display()
701+
);
702+
false
703+
}
689704
// We can't be sure if this is a system interpreter without checking
690705
PythonSource::ProvidedPath
691706
| PythonSource::ParentInterpreter
692707
| PythonSource::ActiveEnvironment
693708
| PythonSource::CondaPrefix
694709
| PythonSource::DiscoveredEnvironment
695-
| PythonSource::SearchPath => !interpreter.is_managed(),
710+
| PythonSource::SearchPath => {
711+
if interpreter.is_managed() {
712+
debug!(
713+
"Ignoring Python interpreter at `{}`: only unmanaged interpreters allowed",
714+
interpreter.sys_executable().display()
715+
);
716+
false
717+
} else {
718+
true
719+
}
720+
}
696721
// Managed interpreters should never be found in these sources
697722
PythonSource::Registry | PythonSource::MicrosoftStore => true,
698723
},

0 commit comments

Comments
 (0)