Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PyPy3.11 #4760

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
Draft
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
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ jobs:
"3.13",
"pypy3.9",
mattip marked this conversation as resolved.
Show resolved Hide resolved
"pypy3.10",
"pypy3.11-nightly",
"graalpy24.0",
]
platform:
Expand Down
1 change: 1 addition & 0 deletions newsfragments/4760.packaging.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add support for PyPy3.11
6 changes: 3 additions & 3 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
PYO3_GUIDE_TARGET = PYO3_TARGET / "guide"
PYO3_DOCS_TARGET = PYO3_TARGET / "doc"
PY_VERSIONS = ("3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13")
PYPY_VERSIONS = ("3.9", "3.10")
PYPY_VERSIONS = ("3.9", "3.10", "3.11")
FREE_THREADED_BUILD = bool(sysconfig.get_config_var("Py_GIL_DISABLED"))


Expand Down Expand Up @@ -689,8 +689,8 @@ def test_version_limits(session: nox.Session):
config_file.set("PyPy", "3.8")
_run_cargo(session, "check", env=env, expect_error=True)

assert "3.11" not in PYPY_VERSIONS
config_file.set("PyPy", "3.11")
assert "3.12" not in PYPY_VERSIONS
config_file.set("PyPy", "3.12")
_run_cargo(session, "check", env=env, expect_error=True)


Expand Down
2 changes: 1 addition & 1 deletion pyo3-ffi/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const SUPPORTED_VERSIONS_PYPY: SupportedVersions = SupportedVersions {
min: PythonVersion { major: 3, minor: 9 },
max: PythonVersion {
major: 3,
minor: 10,
minor: 11,
},
};

Expand Down
10 changes: 8 additions & 2 deletions pyo3-ffi/src/abstract_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,19 @@ use libc::size_t;
use std::os::raw::{c_char, c_int};

#[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())
}

#[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())
}
Expand Down
2 changes: 1 addition & 1 deletion pyo3-ffi/src/cpython/abstract_.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
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;

Expand Down
4 changes: 2 additions & 2 deletions pyo3-ffi/src/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ extern "C" {
arg2: *const c_char,
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;
#[cfg_attr(PyPy, link_name = "PyPyObject_HasAttrString")]
Expand All @@ -460,7 +460,7 @@ extern "C" {
#[cfg_attr(PyPy, link_name = "PyPyObject_SetAttr")]
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;
#[cfg_attr(PyPy, link_name = "PyPyObject_HasAttr")]
Expand Down
2 changes: 1 addition & 1 deletion pyo3-ffi/src/pybuffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ extern "C" {
}

/// 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!(PyPy) { 36 } else { 64 };

/* Flags for getting buffers */
pub const PyBUF_SIMPLE: c_int = 0;
Expand Down
1 change: 1 addition & 0 deletions pyo3-ffi/src/pyerrors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ extern "C" {
#[cfg_attr(PyPy, link_name = "PyPyExc_BaseException")]
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")]
pub static mut PyExc_Exception: *mut PyObject;
Expand Down
Loading