Allow selection of debug build interpreters (#11520)
Extends the `PythonVariant` logic to support interpreters with the debug flag enabled.
This commit is contained in:
@@ -37,6 +37,7 @@ use crate::{
|
||||
use windows::Win32::Foundation::{APPMODEL_ERROR_NO_PACKAGE, ERROR_CANT_ACCESS_FILE, WIN32_ERROR};
|
||||
|
||||
/// A Python executable and its associated platform markers.
|
||||
#[allow(clippy::struct_excessive_bools)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Interpreter {
|
||||
platform: Platform,
|
||||
@@ -59,6 +60,7 @@ pub struct Interpreter {
|
||||
pointer_size: PointerSize,
|
||||
gil_disabled: bool,
|
||||
real_executable: PathBuf,
|
||||
debug_enabled: bool,
|
||||
}
|
||||
|
||||
impl Interpreter {
|
||||
@@ -82,6 +84,7 @@ impl Interpreter {
|
||||
sys_base_exec_prefix: info.sys_base_exec_prefix,
|
||||
pointer_size: info.pointer_size,
|
||||
gil_disabled: info.gil_disabled,
|
||||
debug_enabled: info.debug_enabled,
|
||||
sys_base_prefix: info.sys_base_prefix,
|
||||
sys_base_executable: info.sys_base_executable,
|
||||
sys_executable: info.sys_executable,
|
||||
@@ -212,7 +215,13 @@ impl Interpreter {
|
||||
|
||||
pub fn variant(&self) -> PythonVariant {
|
||||
if self.gil_disabled() {
|
||||
PythonVariant::Freethreaded
|
||||
if self.debug_enabled() {
|
||||
PythonVariant::FreethreadedDebug
|
||||
} else {
|
||||
PythonVariant::Freethreaded
|
||||
}
|
||||
} else if self.debug_enabled() {
|
||||
PythonVariant::Debug
|
||||
} else {
|
||||
PythonVariant::default()
|
||||
}
|
||||
@@ -508,6 +517,12 @@ impl Interpreter {
|
||||
self.gil_disabled
|
||||
}
|
||||
|
||||
/// Return whether this is a debug build of Python, as specified by the sysconfig var
|
||||
/// `Py_DEBUG`.
|
||||
pub fn debug_enabled(&self) -> bool {
|
||||
self.debug_enabled
|
||||
}
|
||||
|
||||
/// Return the `--target` directory for this interpreter, if any.
|
||||
pub fn target(&self) -> Option<&Target> {
|
||||
self.target.as_ref()
|
||||
@@ -877,6 +892,7 @@ pub enum InterpreterInfoError {
|
||||
EmscriptenNotPyodide,
|
||||
}
|
||||
|
||||
#[allow(clippy::struct_excessive_bools)]
|
||||
#[derive(Debug, Deserialize, Serialize, Clone)]
|
||||
struct InterpreterInfo {
|
||||
platform: Platform,
|
||||
@@ -895,6 +911,7 @@ struct InterpreterInfo {
|
||||
standalone: bool,
|
||||
pointer_size: PointerSize,
|
||||
gil_disabled: bool,
|
||||
debug_enabled: bool,
|
||||
}
|
||||
|
||||
impl InterpreterInfo {
|
||||
@@ -1299,7 +1316,8 @@ mod tests {
|
||||
"scripts": "bin"
|
||||
},
|
||||
"pointer_size": "64",
|
||||
"gil_disabled": true
|
||||
"gil_disabled": true,
|
||||
"debug_enabled": false
|
||||
}
|
||||
"##};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user