Don't link to python3.lib for PyPy on Windows

This commit is contained in:
messense 2021-11-15 13:24:29 +08:00
parent e16024fc95
commit f01595163c
1 changed files with 53 additions and 8 deletions

View File

@ -219,7 +219,12 @@ print("mingw", get_platform().startswith("mingw"))
let implementation = map["implementation"].parse()?; let implementation = map["implementation"].parse()?;
let lib_name = if cfg!(windows) { let lib_name = if cfg!(windows) {
default_lib_name_windows(version, abi3, map["mingw"].as_str() == "True") default_lib_name_windows(
version,
implementation,
abi3,
map["mingw"].as_str() == "True",
)
} else { } else {
default_lib_name_unix( default_lib_name_unix(
version, version,
@ -987,7 +992,12 @@ fn windows_hardcoded_cross_compile(
version, version,
shared: true, shared: true,
abi3, abi3,
lib_name: Some(default_lib_name_windows(version, abi3, false)), lib_name: Some(default_lib_name_windows(
version,
PythonImplementation::CPython,
abi3,
false,
)),
lib_dir: cross_compile_config.lib_dir.to_str().map(String::from), lib_dir: cross_compile_config.lib_dir.to_str().map(String::from),
executable: None, executable: None,
pointer_width: None, pointer_width: None,
@ -1026,8 +1036,13 @@ fn load_cross_compile_config(
// This contains only the limited ABI symbols. // This contains only the limited ABI symbols.
const WINDOWS_ABI3_LIB_NAME: &str = "python3"; const WINDOWS_ABI3_LIB_NAME: &str = "python3";
fn default_lib_name_windows(version: PythonVersion, abi3: bool, mingw: bool) -> String { fn default_lib_name_windows(
if abi3 { version: PythonVersion,
implementation: PythonImplementation,
abi3: bool,
mingw: bool,
) -> String {
if abi3 && !implementation.is_pypy() {
WINDOWS_ABI3_LIB_NAME.to_owned() WINDOWS_ABI3_LIB_NAME.to_owned()
} else if mingw { } else if mingw {
// https://packages.msys2.org/base/mingw-w64-python // https://packages.msys2.org/base/mingw-w64-python
@ -1387,22 +1402,52 @@ mod tests {
#[test] #[test]
fn default_lib_name_windows() { fn default_lib_name_windows() {
use PythonImplementation::*;
assert_eq!( assert_eq!(
super::default_lib_name_windows(PythonVersion { major: 3, minor: 6 }, false, false), super::default_lib_name_windows(
PythonVersion { major: 3, minor: 6 },
CPython,
false,
false
),
"python36", "python36",
); );
assert_eq!( assert_eq!(
super::default_lib_name_windows(PythonVersion { major: 3, minor: 6 }, true, false), super::default_lib_name_windows(
PythonVersion { major: 3, minor: 6 },
CPython,
true,
false
),
"python3", "python3",
); );
assert_eq!( assert_eq!(
super::default_lib_name_windows(PythonVersion { major: 3, minor: 6 }, false, true), super::default_lib_name_windows(
PythonVersion { major: 3, minor: 6 },
CPython,
false,
true
),
"python3.6", "python3.6",
); );
assert_eq!( assert_eq!(
super::default_lib_name_windows(PythonVersion { major: 3, minor: 6 }, true, true), super::default_lib_name_windows(
PythonVersion { major: 3, minor: 6 },
CPython,
true,
true
),
"python3", "python3",
); );
assert_eq!(
super::default_lib_name_windows(
PythonVersion { major: 3, minor: 6 },
PyPy,
true,
false
),
"python36",
);
} }
#[test] #[test]