This may or may not be correct, but maturin itself does not use pyo3 and it should be fine as long as the tests pass (aka, it builds rust packages for tests, and these are the ones using pyo3). [patch] directive is used to override the (older) pyo3-ffi that is also vendored but patch does not apply to, this also skip checking hashes at same time. Note that it prints a harmless warning when done here for packages that do not use pyo3-ffi but this is simpler than doing it per-test-package. https://github.com/PyO3/pyo3/pull/4760 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -4,2 +4,5 @@ [source.vendored-sources] directory = "vendor" + +[patch.crates-io] +pyo3-ffi = { path = "vendor/pyo3-ffi-0.23.4" } --- a/vendor/pyo3-ffi-0.23.4/build.rs +++ b/vendor/pyo3-ffi-0.23.4/build.rs @@ -26,5 +26,5 @@ max: PythonVersion { major: 3, - minor: 10, + minor: 11, }, }; --- a/vendor/pyo3-ffi-0.23.4/src/abstract_.rs +++ b/vendor/pyo3-ffi-0.23.4/src/abstract_.rs @@ -4,5 +4,8 @@ #[inline] -#[cfg(all(not(Py_3_13), not(PyPy)))] // CPython exposed as a function in 3.13, in object.h +#[cfg(all( + not(Py_3_13), // CPython exposed as a function in 3.13, in object.h + not(all(PyPy, not(Py_3_11))) // PyPy exposed as a function until PyPy 3.10, macro in 3.11+ +))] pub unsafe fn PyObject_DelAttrString(o: *mut PyObject, attr_name: *const c_char) -> c_int { PyObject_SetAttrString(o, attr_name, std::ptr::null_mut()) @@ -10,5 +13,8 @@ #[inline] -#[cfg(all(not(Py_3_13), not(PyPy)))] // CPython exposed as a function in 3.13, in object.h +#[cfg(all( + not(Py_3_13), // CPython exposed as a function in 3.13, in object.h + not(all(PyPy, not(Py_3_11))) // PyPy exposed as a function until PyPy 3.10, macro in 3.11+ +))] pub unsafe fn PyObject_DelAttr(o: *mut PyObject, attr_name: *mut PyObject) -> c_int { PyObject_SetAttr(o, attr_name, std::ptr::null_mut()) --- a/vendor/pyo3-ffi-0.23.4/src/cpython/abstract_.rs +++ b/vendor/pyo3-ffi-0.23.4/src/cpython/abstract_.rs @@ -1,4 +1,4 @@ use crate::{PyObject, Py_ssize_t}; -#[cfg(not(all(Py_3_11, GraalPy)))] +#[cfg(any(all(Py_3_8, not(any(PyPy, GraalPy))), not(Py_3_11)))] use std::os::raw::c_char; use std::os::raw::c_int; --- a/vendor/pyo3-ffi-0.23.4/src/cpython/genobject.rs +++ b/vendor/pyo3-ffi-0.23.4/src/cpython/genobject.rs @@ -3,5 +3,5 @@ #[cfg(not(any(PyPy, GraalPy)))] use crate::_PyErr_StackItem; -#[cfg(all(Py_3_11, not(GraalPy)))] +#[cfg(all(Py_3_11, not(any(PyPy, GraalPy))))] use std::os::raw::c_char; use std::os::raw::c_int; --- a/vendor/pyo3-ffi-0.23.4/src/cpython/mod.rs +++ b/vendor/pyo3-ffi-0.23.4/src/cpython/mod.rs @@ -72,5 +72,5 @@ pub use self::pydebug::*; pub use self::pyerrors::*; -#[cfg(Py_3_11)] +#[cfg(all(Py_3_11, not(PyPy)))] pub use self::pyframe::*; #[cfg(all(Py_3_8, not(PyPy)))] --- a/vendor/pyo3-ffi-0.23.4/src/cpython/object.rs +++ b/vendor/pyo3-ffi-0.23.4/src/cpython/object.rs @@ -311,7 +311,7 @@ #[cfg(Py_3_9)] pub ht_module: *mut object::PyObject, - #[cfg(Py_3_11)] + #[cfg(all(Py_3_11, not(PyPy)))] _ht_tpname: *mut c_char, - #[cfg(Py_3_11)] + #[cfg(all(Py_3_11, not(PyPy)))] _spec_cache: _specialization_cache, } --- a/vendor/pyo3-ffi-0.23.4/src/cpython/objimpl.rs +++ b/vendor/pyo3-ffi-0.23.4/src/cpython/objimpl.rs @@ -1,3 +1,3 @@ -#[cfg(not(all(Py_3_11, GraalPy)))] +#[cfg(not(all(Py_3_11, any(PyPy, GraalPy))))] use libc::size_t; use std::os::raw::c_int; --- a/vendor/pyo3-ffi-0.23.4/src/cpython/pyframe.rs +++ b/vendor/pyo3-ffi-0.23.4/src/cpython/pyframe.rs @@ -1,2 +1,2 @@ -#[cfg(Py_3_11)] +#[cfg(all(Py_3_11, not(PyPy)))] opaque_struct!(_PyInterpreterFrame); --- a/vendor/pyo3-ffi-0.23.4/src/cpython/pystate.rs +++ b/vendor/pyo3-ffi-0.23.4/src/cpython/pystate.rs @@ -70,5 +70,5 @@ } -#[cfg(all(Py_3_9, not(Py_3_11)))] +#[cfg(all(Py_3_9, not(any(Py_3_11, PyPy))))] pub type _PyFrameEvalFunction = extern "C" fn( *mut crate::PyThreadState, @@ -77,5 +77,5 @@ ) -> *mut crate::object::PyObject; -#[cfg(Py_3_11)] +#[cfg(all(Py_3_11, not(PyPy)))] pub type _PyFrameEvalFunction = extern "C" fn( *mut crate::PyThreadState, @@ -84,5 +84,5 @@ ) -> *mut crate::object::PyObject; -#[cfg(Py_3_9)] +#[cfg(all(Py_3_9, not(PyPy)))] extern "C" { /// Get the frame evaluation function. --- a/vendor/pyo3-ffi-0.23.4/src/cpython/unicodeobject.rs +++ b/vendor/pyo3-ffi-0.23.4/src/cpython/unicodeobject.rs @@ -1,3 +1,3 @@ -#[cfg(not(PyPy))] +#[cfg(any(Py_3_11, not(PyPy)))] use crate::Py_hash_t; use crate::{PyObject, Py_UCS1, Py_UCS2, Py_UCS4, Py_ssize_t}; @@ -252,5 +252,5 @@ pub ob_base: PyObject, pub length: Py_ssize_t, - #[cfg(not(PyPy))] + #[cfg(any(Py_3_11, not(PyPy)))] pub hash: Py_hash_t, /// A bit field with various properties. --- a/vendor/pyo3-ffi-0.23.4/src/object.rs +++ b/vendor/pyo3-ffi-0.23.4/src/object.rs @@ -437,5 +437,5 @@ arg3: *mut PyObject, ) -> c_int; - #[cfg(any(Py_3_13, PyPy))] // CPython defined in 3.12 as an inline function in abstract.h + #[cfg(any(Py_3_13, all(PyPy, not(Py_3_11))))] // CPython defined in 3.12 as an inline function in abstract.h #[cfg_attr(PyPy, link_name = "PyPyObject_DelAttrString")] pub fn PyObject_DelAttrString(arg1: *mut PyObject, arg2: *const c_char) -> c_int; @@ -461,5 +461,5 @@ pub fn PyObject_SetAttr(arg1: *mut PyObject, arg2: *mut PyObject, arg3: *mut PyObject) -> c_int; - #[cfg(any(Py_3_13, PyPy))] // CPython defined in 3.12 as an inline function in abstract.h + #[cfg(any(Py_3_13, all(PyPy, not(Py_3_11))))] // CPython defined in 3.12 as an inline function in abstract.h #[cfg_attr(PyPy, link_name = "PyPyObject_DelAttr")] pub fn PyObject_DelAttr(arg1: *mut PyObject, arg2: *mut PyObject) -> c_int; --- a/vendor/pyo3-ffi-0.23.4/src/pybuffer.rs +++ b/vendor/pyo3-ffi-0.23.4/src/pybuffer.rs @@ -104,5 +104,9 @@ /// Maximum number of dimensions -pub const PyBUF_MAX_NDIM: c_int = if cfg!(PyPy) { 36 } else { 64 }; +pub const PyBUF_MAX_NDIM: usize = if cfg!(all(PyPy, not(Py_3_11))) { + 36 +} else { + 64 +}; /* Flags for getting buffers */ --- a/vendor/pyo3-ffi-0.23.4/src/pyerrors.rs +++ b/vendor/pyo3-ffi-0.23.4/src/pyerrors.rs @@ -117,4 +117,5 @@ pub static mut PyExc_BaseException: *mut PyObject; #[cfg(Py_3_11)] + #[cfg_attr(PyPy, link_name = "PyPyExc_BaseExceptionGroup")] pub static mut PyExc_BaseExceptionGroup: *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyExc_Exception")]