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

Bump supported cpython version to 3.14 for testing #4811

Open
wants to merge 39 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
8efb65b
Add news item
clin1234 Dec 21, 2024
2aa43a2
Move news file
clin1234 Dec 22, 2024
4d0589f
Fix version limit check in noxfile.py
clin1234 Dec 22, 2024
5df3b1c
Bump Python version for testing debug builds
clin1234 Dec 24, 2024
ad3cfbd
3.14 is available from GH's setup-python action
clin1234 Dec 24, 2024
92ea50d
Bump maximum supported CPython version in pyo3-ffi
clin1234 Jan 17, 2025
24a1075
Rework PyASCIIObject and PyUnicodeObject to be compatible with 3.14
clin1234 Jan 21, 2025
49342e6
Run `cargo fmt --all`
clin1234 Jan 21, 2025
9ae3e4a
Actually add Py_3_14 as a legitimate macro
clin1234 Jan 23, 2025
7556d93
Revert "Actually add Py_3_14 as a legitimate macro"
clin1234 Jan 23, 2025
620e057
Fix version macro placement for 3.14-specific getters and setters
clin1234 Jan 23, 2025
cccc39c
Import 'c_ushort' only if compiling against CPython 3.14 or later
clin1234 Jan 23, 2025
d17c4ca
Add wrapper functions for the statically_allocated field
clin1234 Jan 23, 2025
5c83c39
Remove unused libc::c_ushort
clin1234 Jan 23, 2025
c6e70c5
Add (hopefully) final version-specific macros
clin1234 Jan 23, 2025
107c45d
Port 3.14-specific 64-bit code of Py_INCREF
clin1234 Feb 13, 2025
13014bf
Don't expose PyDictObject.ma_version_tag when building against 3.14 o…
clin1234 Feb 13, 2025
b7bd90a
fix ffi-check on the GIL-enabled ABI
ngoldbaum Feb 20, 2025
4535892
fix older pythons
ngoldbaum Feb 20, 2025
e22fdc2
fix ffi-check on older pythons
ngoldbaum Feb 20, 2025
901d623
WIP: update for 3.14t
ngoldbaum Feb 20, 2025
1753d95
fix ffi-check on the free-threaded build
ngoldbaum Feb 20, 2025
b32adfa
fix clippy
ngoldbaum Feb 20, 2025
16732d8
fix clippy on older python versions
ngoldbaum Feb 20, 2025
52d9799
fix cargo check on the MSRV
ngoldbaum Feb 21, 2025
78a3b6e
fix ffi-check on 3.13t
ngoldbaum Feb 21, 2025
9f664fd
fix CI which is using 3.13.1
ngoldbaum Feb 21, 2025
c40011d
fix copy/paste error in noxfile
ngoldbaum Apr 10, 2025
632288a
update ffi bindings for the latest changes in 3.14
ngoldbaum Apr 10, 2025
46a9ccd
update layout of refcnt field on gil-enabled build
ngoldbaum Apr 10, 2025
3dd439d
delete unused HangThread struct
ngoldbaum Apr 11, 2025
e72ce59
fix ffi-check on GIL-enabled build
ngoldbaum Apr 11, 2025
b25dd5a
Revert "delete unused HangThread struct"
ngoldbaum Apr 11, 2025
0bc929f
config-out HangThread
ngoldbaum Apr 11, 2025
08baf67
fix 3.13 ffi-check
ngoldbaum Apr 11, 2025
d4f75e2
fix debug python build error
ngoldbaum Apr 11, 2025
5c306a7
fix graalpy build
ngoldbaum Apr 11, 2025
529ceee
Ignore DeprecationWarnings from the pytest_asyncio module in tests
clin1234 Apr 11, 2025
514ce4f
Add abi3-py314
clin1234 Apr 11, 2025
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
6 changes: 4 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@ jobs:
"3.12",
"3.13",
"3.13t",
"3.14-dev",
"3.14t-dev",
"pypy3.9",
"pypy3.10",
"pypy3.11",
Expand Down Expand Up @@ -528,8 +530,8 @@ jobs:
components: rust-src
- name: Install python3 standalone debug build with nox
run: |
PBS_RELEASE="20241016"
PBS_PYTHON_VERSION="3.13.0"
PBS_RELEASE="20241219"
PBS_PYTHON_VERSION="3.13.1"
PBS_ARCHIVE="cpython-${PBS_PYTHON_VERSION}+${PBS_RELEASE}-x86_64-unknown-linux-gnu-debug-full.tar.zst"
wget "https://github.com/indygreg/python-build-standalone/releases/download/${PBS_RELEASE}/${PBS_ARCHIVE}"
tar -I zstd -xf "${PBS_ARCHIVE}"
Expand Down
1 change: 1 addition & 0 deletions newsfragments/4811.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Bump supported cpython version to 3.14 for testing
6 changes: 3 additions & 3 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -704,11 +704,11 @@ def test_version_limits(session: nox.Session):
config_file.set("CPython", "3.6")
_run_cargo(session, "check", env=env, expect_error=True)

assert "3.14" not in PY_VERSIONS
config_file.set("CPython", "3.14")
assert "3.15" not in PY_VERSIONS
config_file.set("CPython", "3.15")
_run_cargo(session, "check", env=env, expect_error=True)

# 3.14 CPython should build with forward compatibility
# 3.15 CPython should build with forward compatibility
env["PYO3_USE_ABI3_FORWARD_COMPATIBILITY"] = "1"
_run_cargo(session, "check", env=env)

Expand Down
1 change: 1 addition & 0 deletions pyo3-build-config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ abi3-py310 = ["abi3-py311"]
abi3-py311 = ["abi3-py312"]
abi3-py312 = ["abi3-py313"]
abi3-py313 = ["abi3"]
abi3-py314 = ["abi3"]

[package.metadata.docs.rs]
features = ["resolve-config"]
19 changes: 19 additions & 0 deletions pyo3-ffi-check/build.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
use std::env;
use std::path::PathBuf;

#[derive(Debug)]
struct ParseCallbacks;

impl bindgen::callbacks::ParseCallbacks for ParseCallbacks {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @davidhewitt for the suggestion, this worked like a charm. I don't see a callback API to override struct member names, so I had to leave the hack in the macro for the ob_refcnt field, but this lets us generate the names that pyo3-ffi expects for the type names I override below.

// these are anonymous fields and structs in CPython that we needed to
// invent names for. Bindgen seems to generate stable names, so we remap the
// automatically generated names to the names we invented in the FFI
fn item_name(&self, _original_item_name: &str) -> Option<String> {
if _original_item_name == "_object__bindgen_ty_1__bindgen_ty_1" {
Some("PyObjectObFlagsAndRefcnt".into())
} else if _original_item_name == "_object__bindgen_ty_1" {
Some("PyObjectObRefcnt".into())
} else {
None
}
}
}

fn main() {
let config = pyo3_build_config::get();
let python_include_dir = config
Expand Down Expand Up @@ -29,6 +47,7 @@ fn main() {
.header("wrapper.h")
.clang_args(clang_args)
.parse_callbacks(Box::new(bindgen::CargoCallbacks::new()))
.parse_callbacks(Box::new(ParseCallbacks))
// blocklist some values which apparently have conflicting definitions on unix
.blocklist_item("FP_NORMAL")
.blocklist_item("FP_SUBNORMAL")
Expand Down
3 changes: 2 additions & 1 deletion pyo3-ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ abi3-py310 = ["abi3-py311", "pyo3-build-config/abi3-py310"]
abi3-py311 = ["abi3-py312", "pyo3-build-config/abi3-py311"]
abi3-py312 = ["abi3-py313", "pyo3-build-config/abi3-py312"]
abi3-py313 = ["abi3", "pyo3-build-config/abi3-py313"]
abi3-py314 = ["abi3", "pyo3-build-config/abi3-py314"]

# Automatically generates `python3.dll` import libraries for Windows targets.
generate-import-lib = ["pyo3-build-config/python3-dll-a"]
Expand All @@ -50,7 +51,7 @@ workspace = true

[package.metadata.cpython]
min-version = "3.7"
max-version = "3.13" # inclusive
max-version = "3.14" # inclusive

[package.metadata.pypy]
min-version = "3.9"
Expand Down
2 changes: 1 addition & 1 deletion pyo3-ffi/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const SUPPORTED_VERSIONS_CPYTHON: SupportedVersions = SupportedVersions {
min: PythonVersion { major: 3, minor: 7 },
max: PythonVersion {
major: 3,
minor: 13,
minor: 14,
},
};

Expand Down
1 change: 1 addition & 0 deletions pyo3-ffi/src/abstract_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pub unsafe fn PyObject_DelAttr(o: *mut PyObject, attr_name: *mut PyObject) -> c_
extern "C" {
#[cfg(all(
not(PyPy),
not(GraalPy),
any(Py_3_10, all(not(Py_LIMITED_API), Py_3_9)) // Added to python in 3.9 but to limited API in 3.10
))]
#[cfg_attr(PyPy, link_name = "PyPyObject_CallNoArgs")]
Expand Down
44 changes: 34 additions & 10 deletions pyo3-ffi/src/cpython/code.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use crate::object::*;
use crate::pyport::Py_ssize_t;

#[allow(unused_imports)]
use libc::uintptr_t;
#[allow(unused_imports)]
use std::os::raw::{c_char, c_int, c_short, c_uchar, c_void};
#[cfg(not(any(PyPy, GraalPy)))]
Expand All @@ -9,14 +11,22 @@ use std::ptr::addr_of_mut;
#[cfg(all(Py_3_8, not(any(PyPy, GraalPy)), not(Py_3_11)))]
opaque_struct!(_PyOpcache);

#[cfg(Py_3_12)]
#[cfg(Py_3_14)]
pub const _PY_MONITORING_TOOL_IDS: usize = 8;
#[cfg(Py_3_14)]
pub const _PY_MONITORING_LOCAL_EVENTS: usize = 11;
#[cfg(all(Py_3_12, not(Py_3_14)))]
pub const _PY_MONITORING_LOCAL_EVENTS: usize = 10;
#[cfg(Py_3_12)]
#[cfg(Py_3_14)]
pub const _PY_MONITORING_UNGROUPED_EVENTS: usize = 16;
#[cfg(all(Py_3_12, not(Py_3_14)))]
pub const _PY_MONITORING_UNGROUPED_EVENTS: usize = 15;
#[cfg(Py_3_12)]
#[cfg(Py_3_14)]
pub const _PY_MONITORING_EVENTS: usize = 17;
#[cfg(all(Py_3_12, not(Py_3_14)))]
pub const _PY_MONITORING_EVENTS: usize = 19;

#[cfg(Py_3_12)]
#[cfg(all(Py_3_12, not(Py_3_14)))]
#[repr(C)]
#[derive(Clone, Copy)]
pub struct _Py_LocalMonitors {
Expand All @@ -27,7 +37,7 @@ pub struct _Py_LocalMonitors {
}],
}

#[cfg(Py_3_12)]
#[cfg(all(Py_3_12, not(Py_3_14)))]
#[repr(C)]
#[derive(Clone, Copy)]
pub struct _Py_GlobalMonitors {
Expand Down Expand Up @@ -56,15 +66,15 @@ pub struct _PyCoCached {
pub _co_freevars: *mut PyObject,
}

#[cfg(Py_3_12)]
#[cfg(all(Py_3_12, not(Py_3_14)))]
#[repr(C)]
#[derive(Copy, Clone)]
pub struct _PyCoLineInstrumentationData {
pub original_opcode: u8,
pub line_delta: i8,
}

#[cfg(Py_3_12)]
#[cfg(all(Py_3_12, not(Py_3_14)))]
#[repr(C)]
#[derive(Copy, Clone)]
pub struct _PyCoMonitoringData {
Expand All @@ -77,6 +87,19 @@ pub struct _PyCoMonitoringData {
pub per_instruction_tools: *mut u8,
}

#[cfg(Py_3_14)]
opaque_struct!(_PyCoMonitoringData);

#[cfg(Py_3_13)]
opaque_struct!(_PyExecutorArray);

#[repr(C)]
#[cfg(all(Py_GIL_DISABLED, Py_3_14))]
pub struct _PyCodeArray {
size: Py_ssize_t,
entries: [c_char; 1],
}

#[cfg(all(not(any(PyPy, GraalPy)), not(Py_3_7)))]
opaque_struct!(PyCodeObject);

Expand Down Expand Up @@ -105,9 +128,6 @@ pub struct PyCodeObject {
pub co_extra: *mut c_void,
}

#[cfg(Py_3_13)]
opaque_struct!(_PyExecutorArray);

#[cfg(all(not(any(PyPy, GraalPy)), Py_3_8, not(Py_3_11)))]
#[repr(C)]
pub struct PyCodeObject {
Expand Down Expand Up @@ -190,8 +210,12 @@ pub struct PyCodeObject {
pub _co_instrumentation_version: libc::uintptr_t,
#[cfg(Py_3_12)]
pub _co_monitoring: *mut _PyCoMonitoringData,
#[cfg(Py_3_14)]
pub _co_unique_id: Py_ssize_t,
pub _co_firsttraceable: c_int,
pub co_extra: *mut c_void,
#[cfg(all(Py_GIL_DISABLED, Py_3_14))]
pub co_tlbc: *mut _PyCodeArray,
pub co_code_adaptive: [c_char; 1],
}

Expand Down
3 changes: 3 additions & 0 deletions pyo3-ffi/src/cpython/dictobject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ pub struct PyDictObject {
Py_3_12,
deprecated(note = "Deprecated in Python 3.12 and will be removed in the future.")
)]
#[cfg(not(Py_3_14))]
pub ma_version_tag: u64,
#[cfg(Py_3_14)]
pub _ma_watcher_tag: u64,
pub ma_keys: *mut PyDictKeysObject,
#[cfg(not(Py_3_11))]
pub ma_values: *mut *mut PyObject,
Expand Down
2 changes: 2 additions & 0 deletions pyo3-ffi/src/cpython/funcobject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ pub struct PyFunctionObject {
pub func_weakreflist: *mut PyObject,
pub func_module: *mut PyObject,
pub func_annotations: *mut PyObject,
#[cfg(Py_3_14)]
pub func_annotate: *mut PyObject,
#[cfg(Py_3_12)]
pub func_typeparams: *mut PyObject,
pub vectorcall: Option<crate::vectorcallfunc>,
Expand Down
9 changes: 6 additions & 3 deletions pyo3-ffi/src/cpython/genobject.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use crate::object::*;
use crate::PyFrameObject;
#[cfg(not(any(PyPy, GraalPy)))]
#[cfg(not(any(PyPy, GraalPy, Py_3_14)))]
use crate::_PyErr_StackItem;
#[cfg(all(Py_3_11, not(any(PyPy, GraalPy))))]
#[cfg(all(Py_3_11, not(any(PyPy, GraalPy, Py_3_14))))]
use std::os::raw::c_char;
use std::os::raw::c_int;
use std::ptr::addr_of_mut;

#[cfg(not(any(PyPy, GraalPy)))]
#[cfg(not(any(PyPy, GraalPy, Py_3_14)))]
#[repr(C)]
pub struct PyGenObject {
pub ob_base: PyObject,
Expand Down Expand Up @@ -35,6 +35,9 @@ pub struct PyGenObject {
pub gi_iframe: [*mut PyObject; 1],
}

#[cfg(all(Py_3_14, not(any(PyPy, GraalPy))))]
opaque_struct!(PyGenObject);

#[cfg_attr(windows, link(name = "pythonXY"))]
extern "C" {
pub static mut PyGen_Type: PyTypeObject;
Expand Down
11 changes: 11 additions & 0 deletions pyo3-ffi/src/cpython/initconfig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ pub struct PyConfig {
pub tracemalloc: c_int,
#[cfg(Py_3_12)]
pub perf_profiling: c_int,
#[cfg(Py_3_14)]
pub remote_debug: c_int,
pub import_time: c_int,
#[cfg(Py_3_11)]
pub code_debug_ranges: c_int,
Expand Down Expand Up @@ -141,10 +143,19 @@ pub struct PyConfig {
pub safe_path: c_int,
#[cfg(Py_3_12)]
pub int_max_str_digits: c_int,
#[cfg(Py_3_14)]
pub thread_inherit_context: c_int,
#[cfg(Py_3_14)]
pub context_aware_warnings: c_int,
// FIXME: this was backported to 3.13.2
#[cfg(all(Py_3_14, target_os = "macos"))]
pub use_system_logger: c_int,
#[cfg(Py_3_13)]
pub cpu_count: c_int,
#[cfg(Py_GIL_DISABLED)]
pub enable_gil: c_int,
#[cfg(all(Py_3_14, Py_GIL_DISABLED))]
pub tlbc_enabled: c_int,
pub pathconfig_warnings: c_int,
#[cfg(Py_3_10)]
pub program_name: *mut wchar_t,
Expand Down
4 changes: 4 additions & 0 deletions pyo3-ffi/src/cpython/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,12 @@ pub struct PyHeapTypeObject {
pub ht_module: *mut object::PyObject,
#[cfg(all(Py_3_11, not(PyPy)))]
_ht_tpname: *mut c_char,
#[cfg(Py_3_14)]
ht_token: *mut c_void,
#[cfg(all(Py_3_11, not(PyPy)))]
_spec_cache: _specialization_cache,
#[cfg(all(Py_GIL_DISABLED, Py_3_14))]
unique_id: Py_ssize_t,
}

impl Default for PyHeapTypeObject {
Expand Down
4 changes: 4 additions & 0 deletions pyo3-ffi/src/cpython/tupleobject.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
use crate::object::*;
#[cfg(Py_3_14)]
use crate::pyport::Py_hash_t;
#[cfg(not(PyPy))]
use crate::pyport::Py_ssize_t;

#[repr(C)]
pub struct PyTupleObject {
pub ob_base: PyVarObject,
#[cfg(Py_3_14)]
pub ob_hash: Py_hash_t,
pub ob_item: [*mut PyObject; 1],
}

Expand Down
Loading
Loading