Created
November 8, 2024 20:50
-
-
Save ngoldbaum/250bbd25fa173155601ebf3d02bb5202 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/pyo3-build-config/src/impl_.rs b/pyo3-build-config/src/impl_.rs | |
index a473f888..e57204f2 100644 | |
--- a/pyo3-build-config/src/impl_.rs | |
+++ b/pyo3-build-config/src/impl_.rs | |
@@ -386,13 +386,7 @@ print("gil_disabled", get_config_var("Py_GIL_DISABLED")) | |
}; | |
let lib_dir = get_key!(sysconfigdata, "LIBDIR").ok().map(str::to_string); | |
let gil_disabled = match sysconfigdata.get_value("Py_GIL_DISABLED") { | |
- Some(value) => { | |
- if value == "1" { | |
- true | |
- } else { | |
- false | |
- } | |
- } | |
+ Some(value) => value == "1", | |
None => false, | |
}; | |
let lib_name = Some(default_lib_name_unix( | |
diff --git a/pyo3-ffi-check/build.rs b/pyo3-ffi-check/build.rs | |
index ca4a17b6..0ae7d421 100644 | |
--- a/pyo3-ffi-check/build.rs | |
+++ b/pyo3-ffi-check/build.rs | |
@@ -8,12 +8,28 @@ fn main() { | |
"import sysconfig; print(sysconfig.get_config_var('INCLUDEPY'), end='');", | |
) | |
.expect("failed to get lib dir"); | |
+ let gil_disabled_on_windows = dbg!(config | |
+ .run_python_script( | |
+ "import sysconfig; import platform; print(sysconfig.get_config_var('Py_GIL_DISABLED') == 1 and platform.system() == 'Windows');", | |
+ ) | |
+ .expect("failed to get Py_GIL_DISABLED").trim_end()) == "True"; | |
+ | |
+ let clang_args = if gil_disabled_on_windows { | |
+ vec![ | |
+ format!("-I{python_include_dir}"), | |
+ "-DPy_GIL_DISABLED".to_string(), | |
+ ] | |
+ } else { | |
+ vec![format!("-I{python_include_dir}")] | |
+ }; | |
+ | |
+ dbg!(&clang_args); | |
println!("cargo:rerun-if-changed=wrapper.h"); | |
let bindings = bindgen::Builder::default() | |
.header("wrapper.h") | |
- .clang_arg(format!("-I{python_include_dir}")) | |
+ .clang_args(clang_args) | |
.parse_callbacks(Box::new(bindgen::CargoCallbacks)) | |
// blocklist some values which apparently have conflicting definitions on unix | |
.blocklist_item("FP_NORMAL") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment