Skip to content

Commit

Permalink
Define Py_LIMITED_API
Browse files Browse the repository at this point in the history
  • Loading branch information
messense committed Dec 14, 2021
1 parent 51a09fe commit 065c2f1
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/rust/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ fn main() {
);
}

let python_impl = run_python_script(
&python,
"import platform; print(platform.python_implementation(), end='')",
)
.unwrap();
let python_include = run_python_script(
&python,
"import sysconfig; print(sysconfig.get_path('include'), end='')",
Expand All @@ -57,13 +62,22 @@ fn main() {
let openssl_include =
std::env::var_os("DEP_OPENSSL_INCLUDE").expect("unable to find openssl include path");
let openssl_c = Path::new(&out_dir).join("_openssl.c");
cc::Build::new()

let mut build = cc::Build::new();
build
.file(openssl_c)
.include(python_include)
.include(openssl_include)
.flag_if_supported("-Wconversion")
.flag_if_supported("-Wno-error=sign-conversion")
.compile("_openssl.a");
.flag_if_supported("-Wno-error=sign-conversion");

// Enable abi3 mode if we're not using PyPy.

This comment has been minimized.

Copy link
@alex

alex Dec 14, 2021

Member

Is there any way we can get this from pyo3-build-config?

This comment has been minimized.

Copy link
@messense

messense Dec 14, 2021

Author

I think it's doable. I've requested pyo3-build-config to expose more information for downstream in PyO3/pyo3#1996 (comment)

if python_impl != "PyPy" {
// cp36
build.define("Py_LIMITED_API", "0x030600f0");
}

build.compile("_openssl.a");
}

/// Run a python script using the specified interpreter binary.
Expand Down

0 comments on commit 065c2f1

Please sign in to comment.