diff --git a/src/build_context.rs b/src/build_context.rs index f1f264c88..edcd0384f 100644 --- a/src/build_context.rs +++ b/src/build_context.rs @@ -234,7 +234,7 @@ impl BuildContext { let interp_names: HashSet<_> = non_abi3_interps .iter() .map(|interp| match interp.interpreter_kind { - InterpreterKind::CPython => interp.implmentation_name.to_string(), + InterpreterKind::CPython => interp.implementation_name.to_string(), InterpreterKind::PyPy => "PyPy".to_string(), }) .collect(); diff --git a/src/build_options.rs b/src/build_options.rs index ef2a1cfc1..f81c62e56 100644 --- a/src/build_options.rs +++ b/src/build_options.rs @@ -292,7 +292,7 @@ impl BuildOptions { executable: PathBuf::new(), platform: None, runnable: false, - implmentation_name: interpreter_kind.to_string().to_ascii_lowercase(), + implementation_name: interpreter_kind.to_string().to_ascii_lowercase(), soabi: soabi.cloned(), }); } else { @@ -360,7 +360,7 @@ impl BuildOptions { executable: PathBuf::new(), platform: None, runnable: false, - implmentation_name: "cpython".to_string(), + implementation_name: "cpython".to_string(), soabi: None, }]) } else if let Some(config_file) = env::var_os("PYO3_CONFIG_FILE") { @@ -387,7 +387,7 @@ impl BuildOptions { executable: PathBuf::new(), platform: None, runnable: false, - implmentation_name: "cpython".to_string(), + implementation_name: "cpython".to_string(), soabi: None, }]) } else { @@ -427,7 +427,7 @@ impl BuildOptions { executable: PathBuf::new(), platform: None, runnable: false, - implmentation_name: "cpython".to_string(), + implementation_name: "cpython".to_string(), soabi: None, }]) } else if target.cross_compiling() { diff --git a/src/python_interpreter/mod.rs b/src/python_interpreter/mod.rs index 7d335b4f5..2838b6f6a 100644 --- a/src/python_interpreter/mod.rs +++ b/src/python_interpreter/mod.rs @@ -364,7 +364,7 @@ pub struct PythonInterpreter { /// and it's `executable` is empty pub runnable: bool, /// Comes from `sys.platform.name` - pub implmentation_name: String, + pub implementation_name: String, /// Comes from sysconfig var `SOABI` pub soabi: Option, } @@ -433,7 +433,7 @@ fn fun_with_abiflags( impl PythonInterpreter { /// Does this interpreter have PEP 384 stable api aka. abi3 support? pub fn has_stable_api(&self) -> bool { - if self.implmentation_name.parse::().is_err() { + if self.implementation_name.parse::().is_err() { false } else { match self.interpreter_kind { @@ -465,12 +465,12 @@ impl PythonInterpreter { } else { context.get_platform_tag(platform_tags)? }; - let tag = if self.implmentation_name.parse::().is_err() { + let tag = if self.implementation_name.parse::().is_err() { // Use generic tags when `sys.implementation.name` != `platform.python_implementation()`, for example Pyston // See also https://github.com/pypa/packaging/blob/0031046f7fad649580bc3127d1cef9157da0dd79/packaging/tags.py#L234-L261 format!( "{interpreter}{major}{minor}-{soabi}-{platform}", - interpreter = self.implmentation_name, + interpreter = self.implementation_name, major = self.major, minor = self.minor, soabi = self @@ -676,20 +676,20 @@ impl PythonInterpreter { executable, platform, runnable: true, - implmentation_name: message.implementation_name, + implementation_name: message.implementation_name, soabi: message.soabi, })) } /// Construct a `PythonInterpreter` from a sysconfig and target pub fn from_config(config: InterpreterConfig) -> Self { - let implmentation_name = config.interpreter_kind.to_string().to_ascii_lowercase(); + let implementation_name = config.interpreter_kind.to_string().to_ascii_lowercase(); PythonInterpreter { config, executable: PathBuf::new(), platform: None, runnable: false, - implmentation_name, + implementation_name, soabi: None, } } @@ -879,7 +879,7 @@ impl PythonInterpreter { let pointer_width = self.pointer_width.unwrap_or(64); format!( "{}-{}.{}-{}bit", - self.implmentation_name, self.major, self.minor, pointer_width + self.implementation_name, self.major, self.minor, pointer_width ) } @@ -928,3 +928,28 @@ impl fmt::Display for PythonInterpreter { } } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_find_interpreter_by_target() { + let target = + Target::from_target_triple(Some("x86_64-unknown-linux-gnu".to_string())).unwrap(); + let pythons = PythonInterpreter::find_by_target(&target, None); + assert_eq!(pythons.len(), 10); + + let pythons = PythonInterpreter::find_by_target( + &target, + Some(&VersionSpecifiers::from_str(">=3.7").unwrap()), + ); + assert_eq!(pythons.len(), 9); + + let pythons = PythonInterpreter::find_by_target( + &target, + Some(&VersionSpecifiers::from_str(">=3.10").unwrap()), + ); + assert_eq!(pythons.len(), 3); + } +}