Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -1111,7 +1111,7 @@ def load_pkg_versions():

@nox.session(name="ffi-check")
def ffi_check(session: nox.Session):
_run_cargo(session, "run", _FFI_CHECK)
_run_cargo(session, "run", _FFI_CHECK, "--message-format=short")
_check_raw_dylib_macro(session)


Expand Down
2 changes: 2 additions & 0 deletions pyo3-ffi-check/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ fn main() {
println!("cargo:rerun-if-changed=definitions");
println!("cargo:rerun-if-changed=../pyo3-ffi");

pyo3_build_config::use_pyo3_cfgs();

// Because `pyo3-ffi` is a dependency, libpython is linked, this ensures `main.rs` can run.
// Slightly needless (no symbols from libpython are actually called), but simple to do.
pyo3_build_config::add_libpython_rpath_link_args();
Expand Down
26 changes: 24 additions & 2 deletions pyo3-ffi-check/definitions/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,19 @@ impl bindgen::callbacks::ParseCallbacks for ParseCallbacks {
}
}

#[derive(Debug)]
struct PyPyReplaceCallbacks;

impl bindgen::callbacks::ParseCallbacks for PyPyReplaceCallbacks {
fn item_name(&self, item_info: ItemInfo<'_>) -> Option<String> {
if item_info.name.starts_with("PyPy") || item_info.name.starts_with("_PyPy") {
Some(item_info.name.replacen("PyPy", "Py", 1))
} else {
None
}
}
}

fn main() {
let config = pyo3_build_config::get();

Expand All @@ -44,11 +57,20 @@ fn main() {

println!("cargo:rerun-if-changed=wrapper.h");

let bindings = bindgen::Builder::default()
let mut builder = bindgen::Builder::default()
.header("wrapper.h")
.clang_args(clang_args)
.parse_callbacks(Box::new(bindgen::CargoCallbacks::new()))
.parse_callbacks(Box::new(ParseCallbacks))
.parse_callbacks(Box::new(ParseCallbacks));

if matches!(
config.implementation,
pyo3_build_config::PythonImplementation::PyPy
) {
builder = builder.parse_callbacks(Box::new(PyPyReplaceCallbacks));
}

let bindings = builder
// blocklist some values which apparently have conflicting definitions on unix
.blocklist_item("FP_NORMAL")
.blocklist_item("FP_SUBNORMAL")
Expand Down
1 change: 1 addition & 0 deletions pyo3-ffi-check/definitions/wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
#include "datetime.h"
#include "frameobject.h"
#include "structmember.h"
#include "marshal.h"
1 change: 1 addition & 0 deletions pyo3-ffi-check/macro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ quote = "1"
proc-macro2 = "1.0.60"
scraper = "0.26"
pyo3-build-config = { path = "../../pyo3-build-config" }
regex = "1.12.3"
Loading
Loading