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 14, 2021
1 parent 18b68ad commit d5279ad
Show file tree
Hide file tree
Showing 4 changed files with 746 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/build_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,7 @@ pub fn find_interpreter(
.context("Could not parse value of version_minor")?;
let abiflags = sysconfig_data
.get("ABIFLAGS")
.filter(|s| !s.is_empty())
.map(ToString::to_string)
.unwrap_or_default();
let ext_suffix = sysconfig_data
Expand Down
4 changes: 2 additions & 2 deletions src/get_interpreter_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
metadata = {
"major": sys.version_info.major,
"minor": sys.version_info.minor,
"abiflags": sysconfig.get_config_var("ABIFLAGS"),
"abiflags": sysconfig.get_config_var("ABIFLAGS") or None,
"interpreter": platform.python_implementation().lower(),
"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
10 changes: 5 additions & 5 deletions src/python_interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,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 @@ -299,10 +299,10 @@ fn fun_with_abiflags(
target: &Target,
bridge: &BridgeModel,
) -> Result<String> {
if bridge != &BridgeModel::Cffi && target.get_python_os() != message.platform {
if bridge != &BridgeModel::Cffi && target.get_python_os() != message.system {
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 @@ -318,7 +318,7 @@ fn fun_with_abiflags(
if message.interpreter == "pypy" {
// pypy does not specify abi flags
Ok("".to_string())
} else if message.platform == "windows" {
} else if message.system == "windows" {
if message.abiflags.is_some() {
bail!("A python 3 interpreter on windows does not define abiflags in its sysconfig ಠ_ಠ")
} else {
Expand Down
Loading

0 comments on commit d5279ad

Please sign in to comment.