Skip to content
Open
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
23 changes: 21 additions & 2 deletions pyo3-build-config/src/impl_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,11 @@ impl InterpreterConfig {
PythonImplementation::RustPython => out.push("cargo:rustc-cfg=RustPython".to_owned()),
}

// If Py_GIL_DISABLED is set, do not build with limited API support
if self.abi3 && !self.is_free_threaded() {
// RustPython always builds with limited API support.
// If Py_GIL_DISABLED is set, do not build with limited API support.
if (self.abi3 && !self.is_free_threaded())
|| self.implementation == PythonImplementation::RustPython
{
out.push("cargo:rustc-cfg=Py_LIMITED_API".to_owned());
}

Expand Down Expand Up @@ -3188,6 +3191,22 @@ mod tests {
"cargo:rustc-cfg=PyPy".to_owned(),
]
);

let interpreter_config =
InterpreterConfigBuilder::new(PythonImplementation::RustPython, version)
.finalize()
.unwrap();
assert_eq!(
interpreter_config.build_script_outputs(),
[
"cargo:rustc-cfg=Py_3_8".to_owned(),
"cargo:rustc-cfg=Py_3_9".to_owned(),
"cargo:rustc-cfg=Py_3_10".to_owned(),
"cargo:rustc-cfg=Py_3_11".to_owned(),
"cargo:rustc-cfg=RustPython".to_owned(),
"cargo:rustc-cfg=Py_LIMITED_API".to_owned(),
]
);
}

#[test]
Expand Down
4 changes: 2 additions & 2 deletions pyo3-ffi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -600,8 +600,8 @@ mod weakrefobject;
pub mod structmember;

// "Limited API" definitions matching Python's `include/cpython` directory.
#[cfg(not(Py_LIMITED_API))]
#[cfg(not(any(Py_LIMITED_API, RustPython)))]
mod cpython;

#[cfg(not(Py_LIMITED_API))]
#[cfg(not(any(Py_LIMITED_API, RustPython)))]
pub use self::cpython::*;
3 changes: 1 addition & 2 deletions src/types/dict.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@ pyobject_native_type!(
);

#[cfg(RustPython)]
pyobject_native_type!(
pyobject_native_type_core!(
PyDict,
ffi::PyDictObject,
|py| {
static TYPE: PyOnceLock<Py<PyType>> = PyOnceLock::new();
TYPE.import(py, "builtins", "dict").unwrap().as_type_ptr()
Expand Down