Skip to content

Commit 6f56e49

Browse files
committed
Don't use limited API for cffi build on free-threaded python
1 parent 6414d09 commit 6f56e49

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/rust/cryptography-cffi/build.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,15 @@ fn main() {
7878
build.include(python_include);
7979
}
8080

81-
// Enable abi3 mode if we're not using PyPy.
82-
if python_impl != "PyPy" {
81+
let is_free_threaded = run_python_script(
82+
&python,
83+
"import sysconfig; print(bool(sysconfig.get_config_var('Py_GIL_DISABLED')), end='')",
84+
)
85+
.unwrap()
86+
== "True";
87+
88+
// Enable abi3 mode if we're not using PyPy or the free-threaded build
89+
if !(python_impl == "PyPy" || is_free_threaded) {
8390
// cp37 (Python 3.7 to help our grep when we some day drop 3.7 support)
8491
build.define("Py_LIMITED_API", "0x030700f0");
8592
}

0 commit comments

Comments
 (0)