mirror of
https://github.com/astral-sh/uv.git
synced 2025-08-29 23:14:11 +00:00
Require opt-in to use alternative Python implementations (#7650)
Closes #7118 This only really affects managed interpreters, as we exclude alternative Python implementations from the search path during the `VersionRequest::executable_names` part of discovery.
This commit is contained in:
parent
da328379c1
commit
a53ddaa24a
6 changed files with 100 additions and 14 deletions
|
@ -25,7 +25,9 @@ use uv_fs::{write_atomic_sync, PythonExt, Simplified};
|
|||
use crate::implementation::LenientImplementationName;
|
||||
use crate::platform::{Arch, Libc, Os};
|
||||
use crate::pointer_size::PointerSize;
|
||||
use crate::{Prefix, PythonInstallationKey, PythonVersion, Target, VirtualEnvironment};
|
||||
use crate::{
|
||||
Prefix, PythonInstallationKey, PythonVersion, Target, VersionRequest, VirtualEnvironment,
|
||||
};
|
||||
|
||||
/// A Python executable and its associated platform markers.
|
||||
#[derive(Debug, Clone)]
|
||||
|
@ -494,6 +496,21 @@ impl Interpreter {
|
|||
(version.major(), version.minor()) == self.python_tuple()
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether or not this Python interpreter is from a default Python executable name, like
|
||||
/// `python`, `python3`, or `python.exe`.
|
||||
pub(crate) fn has_default_executable_name(&self) -> bool {
|
||||
let Some(file_name) = self.sys_executable().file_name() else {
|
||||
return false;
|
||||
};
|
||||
let Some(name) = file_name.to_str() else {
|
||||
return false;
|
||||
};
|
||||
VersionRequest::Default
|
||||
.executable_names(None)
|
||||
.into_iter()
|
||||
.any(|default_name| name == default_name.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
/// The `EXTERNALLY-MANAGED` file in a Python installation.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue