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:
Zanie Blue 2024-09-24 12:52:15 -05:00 committed by GitHub
parent da328379c1
commit a53ddaa24a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 100 additions and 14 deletions

View file

@ -16,7 +16,8 @@ use crate::implementation::LenientImplementationName;
use crate::managed::{ManagedPythonInstallation, ManagedPythonInstallations};
use crate::platform::{Arch, Libc, Os};
use crate::{
downloads, Error, Interpreter, PythonDownloads, PythonPreference, PythonSource, PythonVersion,
downloads, Error, ImplementationName, Interpreter, PythonDownloads, PythonPreference,
PythonSource, PythonVersion,
};
/// A Python interpreter and accompanying tools.
@ -176,6 +177,16 @@ impl PythonInstallation {
LenientImplementationName::from(self.interpreter.implementation_name())
}
/// Whether this is a CPython installation.
///
/// Returns false if it is an alternative implementation, e.g., PyPy.
pub(crate) fn is_alternative_implementation(&self) -> bool {
!matches!(
self.implementation(),
LenientImplementationName::Known(ImplementationName::CPython)
)
}
/// Return the [`Arch`] of the Python installation as reported by its interpreter.
pub fn arch(&self) -> Arch {
self.interpreter.arch()