mirror of
https://github.com/astral-sh/uv.git
synced 2025-10-28 02:40:11 +00:00
Improve logging of interpreter implementation (#3791)
``` Found Python interpreter CPython 3.12.3 at... ``` instead of ``` Found Python interpreter cpython 3.12.3 at ```
This commit is contained in:
parent
81eff0ecc8
commit
306a4d7ce3
2 changed files with 26 additions and 2 deletions
|
|
@ -6,7 +6,7 @@ use uv_fs::Simplified;
|
||||||
use uv_warnings::warn_user_once;
|
use uv_warnings::warn_user_once;
|
||||||
use which::which;
|
use which::which;
|
||||||
|
|
||||||
use crate::implementation::ImplementationName;
|
use crate::implementation::{ImplementationName, LenientImplementationName};
|
||||||
use crate::interpreter::Error as InterpreterError;
|
use crate::interpreter::Error as InterpreterError;
|
||||||
use crate::managed::toolchains_for_current_platform;
|
use crate::managed::toolchains_for_current_platform;
|
||||||
use crate::py_launcher::py_list_paths;
|
use crate::py_launcher::py_list_paths;
|
||||||
|
|
@ -366,7 +366,7 @@ fn python_interpreters<'a>(
|
||||||
.inspect(|(source, interpreter)| {
|
.inspect(|(source, interpreter)| {
|
||||||
trace!(
|
trace!(
|
||||||
"Found Python interpreter {} {} at {} from {source}",
|
"Found Python interpreter {} {} at {} from {source}",
|
||||||
interpreter.implementation_name(),
|
LenientImplementationName::from(interpreter.implementation_name()),
|
||||||
interpreter.python_full_version(),
|
interpreter.python_full_version(),
|
||||||
path.display()
|
path.display()
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,12 @@ pub enum ImplementationName {
|
||||||
PyPy,
|
PyPy,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Eq, PartialEq, Clone)]
|
||||||
|
pub(crate) enum LenientImplementationName {
|
||||||
|
Known(ImplementationName),
|
||||||
|
Unknown(String),
|
||||||
|
}
|
||||||
|
|
||||||
impl ImplementationName {
|
impl ImplementationName {
|
||||||
pub(crate) fn iter() -> impl Iterator<Item = &'static ImplementationName> {
|
pub(crate) fn iter() -> impl Iterator<Item = &'static ImplementationName> {
|
||||||
static NAMES: &[ImplementationName] =
|
static NAMES: &[ImplementationName] =
|
||||||
|
|
@ -52,3 +58,21 @@ impl Display for ImplementationName {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<&str> for LenientImplementationName {
|
||||||
|
fn from(s: &str) -> Self {
|
||||||
|
match ImplementationName::from_str(s) {
|
||||||
|
Ok(implementation) => Self::Known(implementation),
|
||||||
|
Err(_) => Self::Unknown(s.to_string()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Display for LenientImplementationName {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
match self {
|
||||||
|
Self::Known(implementation) => implementation.fmt(f),
|
||||||
|
Self::Unknown(name) => f.write_str(name),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue