Consolidate PythonPreference enforcement (#18567)
This commit is contained in:
@@ -38,6 +38,14 @@ pub struct PythonInstallation {
|
||||
}
|
||||
|
||||
impl PythonInstallation {
|
||||
/// Create a new [`PythonInstallation`] from a source and interpreter.
|
||||
pub fn new(source: PythonSource, interpreter: Interpreter) -> Self {
|
||||
Self {
|
||||
source,
|
||||
interpreter,
|
||||
}
|
||||
}
|
||||
|
||||
/// Find an installed [`PythonInstallation`].
|
||||
///
|
||||
/// This is the standard interface for discovering a Python installation for creating
|
||||
@@ -350,6 +358,13 @@ impl PythonInstallation {
|
||||
LenientImplementationName::from(self.interpreter.implementation_name())
|
||||
}
|
||||
|
||||
/// Returns `true` if this is a managed (uv-installed) Python installation.
|
||||
///
|
||||
/// Uses the source as a fast path, then falls back to checking the interpreter's base prefix.
|
||||
pub fn is_managed(&self) -> bool {
|
||||
self.source.is_managed() || self.interpreter.is_managed()
|
||||
}
|
||||
|
||||
/// Whether this is a CPython installation.
|
||||
///
|
||||
/// Returns false if it is an alternative implementation, e.g., PyPy.
|
||||
|
||||
Reference in New Issue
Block a user