Skip to content

Commit

Permalink
Relax abiflags check for Python on Windows mingw platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
messense committed Nov 15, 2021
1 parent 9fc92e6 commit a294ee7
Show file tree
Hide file tree
Showing 3 changed files with 747 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/get_interpreter_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"ext_suffix": ext_suffix,
"abi_tag": (sysconfig.get_config_var("SOABI") or "-").split("-")[1] or None,
# This one isn't technically necessary, but still very useful for sanity checks
"platform": platform.system().lower(),
"system": platform.system().lower(),
# We need this one for windows abi3 builds
"base_prefix": sys.base_prefix,
}
Expand Down
16 changes: 8 additions & 8 deletions src/python_interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ struct IntepreterMetadataMessage {
abiflags: Option<String>,
interpreter: String,
ext_suffix: Option<String>,
platform: String,
system: String,
abi_tag: Option<String>,
base_prefix: String,
}
Expand Down Expand Up @@ -301,12 +301,12 @@ fn fun_with_abiflags(
bridge: &BridgeModel,
) -> Result<String> {
if bridge != &BridgeModel::Cffi
&& target.get_python_os() != message.platform
&& target.get_python_os() != message.system
&& !is_cross_compiling(target)?
{
bail!(
"sys.platform in python, {}, and the rust target, {:?}, don't match ಠ_ಠ",
message.platform,
"platform.system() in python, {}, and the rust target, {:?}, don't match ಠ_ಠ",
message.system,
target,
)
}
Expand All @@ -322,11 +322,11 @@ fn fun_with_abiflags(
if message.interpreter == "pypy" {
// pypy does not specify abi flags
Ok("".to_string())
} else if message.platform == "windows" {
if message.abiflags.is_some() {
bail!("A python 3 interpreter on windows does not define abiflags in its sysconfig ಠ_ಠ")
} else {
} else if message.system == "windows" {
if matches!(message.abiflags.as_deref(), Some("") | None) {
Ok("".to_string())
} else {
bail!("A python 3 interpreter on windows does not define abiflags in its sysconfig ಠ_ಠ")
}
} else if let Some(ref abiflags) = message.abiflags {
if message.minor >= 8 {
Expand Down
Loading

0 comments on commit a294ee7

Please sign in to comment.