Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
127 commits
Select commit Hold shift + click to select a range
f1781c4
refactor: add backend module skeleton
smarcd Apr 12, 2026
31de66d
refactor: add backend-neutral macro specs
smarcd Apr 12, 2026
c6a8165
feat: add RustPython backend skeleton
smarcd Apr 12, 2026
a625a8f
refactor: make runtime backend selection coherent
smarcd Apr 12, 2026
78f4c18
refactor: align CPython-family backend shell
smarcd Apr 12, 2026
55753f9
refactor: expose active backend selection
smarcd Apr 12, 2026
32d62a0
feat: add RustPython no-libpython build path
smarcd Apr 12, 2026
1df6124
refactor: make runtime cfg selection contractual
smarcd Apr 12, 2026
9a3b0d4
refactor: split RustPython FFI modules and dynamic builtin types
smarcd Apr 12, 2026
5c673f2
refactor: split RustPython dict list and module ffi families
smarcd Apr 12, 2026
628f3f9
refactor: split RustPython numeric and slice ffi families
smarcd Apr 12, 2026
69f088f
refactor: split RustPython bytes capsule and warnings ffi families
smarcd Apr 12, 2026
578d197
refactor: add RustPython methodobject backend
smarcd Apr 12, 2026
7c02ec2
refactor: support RustPython pyfunction parsing and builtin inheritance
smarcd Apr 12, 2026
eb7fe8c
fix: preserve RustPython exceptions in runtime helpers
smarcd Apr 12, 2026
45aeec1
refactor: advance RustPython runtime subclassing
smarcd Apr 12, 2026
0794935
fix: preserve module and exception constructor semantics
smarcd Apr 12, 2026
9e0459e
fix: improve RustPython sequence and property handling
smarcd Apr 12, 2026
dd2e80f
test: add RustPython worker-thread import reproducer
smarcd Apr 12, 2026
0653c94
test: mark RustPython worker-thread import repro as blocked upstream
smarcd Apr 13, 2026
2adeb99
fix: improve RustPython module and eval error paths
smarcd Apr 13, 2026
48d85bc
fix: advance RustPython runtime and traceback support
smarcd Apr 13, 2026
2d3c2d8
fix: correct RustPython refcount and detach state
smarcd Apr 13, 2026
cf14c0d
fix: stabilize RustPython pyclass inheritance layout
smarcd Apr 13, 2026
71cb3d7
fix: align RustPython frozen-field and time conversion semantics
smarcd Apr 13, 2026
88ab25d
test: mark RustPython datetime import blocker in pyfunction suite
smarcd Apr 13, 2026
4dc2b05
test: mark RustPython array import blocker in pyfunction suite
smarcd Apr 13, 2026
9be424f
fix: advance RustPython FFI error and datetime semantics
smarcd Apr 13, 2026
16a844a
fix: resolve RustPython dict view types dynamically
smarcd Apr 13, 2026
b98a078
fix: align RustPython dict lookup and hash slot semantics
smarcd Apr 13, 2026
699b4e8
fix: advance RustPython tuple string and weakref support
smarcd Apr 13, 2026
67f7c4e
test: xfail RustPython weakref blockers and tighten backend semantics
smarcd Apr 13, 2026
3254b30
refactor: preserve callable slot semantics across backends
smarcd Apr 13, 2026
2ae21da
fix: tie RustPython sidecar lifetime to heap teardown
smarcd Apr 13, 2026
3fbaf1a
fix: align RustPython set checks and heap buffer semantics
smarcd Apr 13, 2026
bd201f0
fix: advance RustPython class and macro semantics
smarcd Apr 13, 2026
b75d276
fix: advance RustPython startup and mapping semantics
smarcd Apr 14, 2026
96f1351
fix: complete RustPython text signatures and classify import blockers
smarcd Apr 14, 2026
b04fbdc
fix: restore weakref coverage on RustPython
smarcd Apr 14, 2026
7c0b400
chore: reduce RustPython backend warning noise
smarcd Apr 14, 2026
8871532
fix: restore CPython downstream compatibility
smarcd Apr 14, 2026
52f35f5
fix: restore downstream constructor compatibility
smarcd Apr 14, 2026
4a279a1
refactor: scaffold backend dispatcher boundaries
smarcd Apr 15, 2026
4dfb51b
refactor: dispatch runtime and error state through backend modules
smarcd Apr 15, 2026
dfe2d02
refactor: dispatch pyclass and sync surfaces through backend modules
smarcd Apr 15, 2026
5b38d6c
refactor: dispatch datetime and container surfaces through backend mo…
smarcd Apr 15, 2026
60adacf
refactor: dispatch complex ffi surfaces through backend modules
smarcd Apr 15, 2026
e4dc763
refactor: dispatch list ffi surfaces through backend modules
smarcd Apr 15, 2026
9c0452f
refactor: dispatch dict ffi surfaces through backend modules
smarcd Apr 15, 2026
366c4b9
refactor: dispatch tuple ffi surfaces through backend modules
smarcd Apr 15, 2026
8894c08
refactor: dispatch set ffi surfaces through backend modules
smarcd Apr 15, 2026
8075863
refactor: dispatch bytes ffi surfaces through backend modules
smarcd Apr 15, 2026
a061f52
refactor: dispatch float ffi surfaces through backend modules
smarcd Apr 16, 2026
aa68a8f
refactor: dispatch bool ffi surfaces through backend modules
smarcd Apr 16, 2026
2b06c57
refactor: dispatch long ffi surfaces through backend modules
smarcd Apr 16, 2026
b44f585
refactor: dispatch bytearray ffi surfaces through backend modules
smarcd Apr 16, 2026
9133ece
refactor: dispatch module ffi surfaces through backend modules
smarcd Apr 16, 2026
648e552
refactor: dispatch capsule ffi surfaces through backend modules
smarcd Apr 16, 2026
657d73d
refactor: dispatch warnings ffi surfaces through backend modules
smarcd Apr 16, 2026
674c63c
refactor: dispatch pymem ffi surfaces through backend modules
smarcd Apr 16, 2026
b0fb4bc
refactor: dispatch pybuffer ffi surfaces through backend modules
smarcd Apr 16, 2026
7083037
refactor: dispatch unicode ffi surfaces through backend modules
smarcd Apr 16, 2026
716201a
refactor: dispatch slice ffi surfaces through backend modules
smarcd Apr 16, 2026
3796d7f
refactor: dispatch refcount ffi surfaces through backend modules
smarcd Apr 16, 2026
043b6c1
refactor: dispatch weakref ffi surfaces through backend modules
smarcd Apr 16, 2026
85ec384
refactor: dispatch descriptor ffi surfaces through backend modules
smarcd Apr 16, 2026
795fd43
refactor: dispatch pyerrors ffi surfaces through backend modules
smarcd Apr 16, 2026
352bbc6
refactor: dispatch critical section ffi surfaces through backend modules
smarcd Apr 16, 2026
1eb4d30
refactor: dispatch lock ffi surfaces through backend modules
smarcd Apr 16, 2026
9c2d76a
refactor: dispatch datetime ffi surfaces through backend modules
smarcd Apr 16, 2026
f9ebe6e
refactor: dispatch compat py_3_9 ffi surfaces through backend modules
smarcd Apr 16, 2026
e6ffbf2
fix: restore CPython ffi exports for frontend types
smarcd Apr 16, 2026
e73fb1b
refactor: dispatch datetime frontend access through backend types mod…
smarcd Apr 16, 2026
7fb6e0e
refactor: dispatch complex frontend access through backend types modules
smarcd Apr 16, 2026
ab2d2c1
refactor: dispatch slice frontend access through backend types modules
smarcd Apr 16, 2026
e6a2373
refactor: dispatch mappingproxy frontend access through backend types…
smarcd Apr 17, 2026
6b2a20b
refactor: dispatch bytes frontend access through backend types modules
smarcd Apr 17, 2026
0ac2b08
refactor: dispatch capsule frontend access through backend types modules
smarcd Apr 17, 2026
9473b97
refactor: dispatch bytearray frontend access through backend types mo…
smarcd Apr 17, 2026
f0868ef
refactor: dispatch range frontend access through backend types modules
smarcd Apr 17, 2026
d218eb5
refactor: dispatch int frontend access through backend types modules
smarcd Apr 17, 2026
83816f6
refactor: dispatch super frontend access through backend types modules
smarcd Apr 17, 2026
375fcde
refactor: dispatch weakref frontend access through backend types modules
smarcd Apr 17, 2026
ba4fc15
refactor: dispatch traceback frontend access through backend types mo…
smarcd Apr 17, 2026
aaeb886
refactor: dispatch ipaddr conversion tests through backend-neutral gu…
smarcd Apr 17, 2026
d6fa087
refactor: dispatch path conversion tests through backend-neutral guards
smarcd Apr 17, 2026
c2738a0
refactor: dispatch numeric extraction through backend-neutral selection
smarcd Apr 17, 2026
294bb16
refactor: dispatch array extraction through backend-neutral selection
smarcd Apr 17, 2026
f26e1b0
refactor: dispatch vec extraction through backend-neutral selection
smarcd Apr 17, 2026
37c5310
refactor: dispatch iterator test guards through backend-neutral selec…
smarcd Apr 17, 2026
01d2d81
refactor: dispatch err test guards through backend-neutral selection
smarcd Apr 17, 2026
acef706
refactor: dispatch code frontend access through backend types modules
smarcd Apr 17, 2026
3d971c0
refactor: dispatch suspend-attach state through backend-neutral selec…
smarcd Apr 17, 2026
a0f940e
refactor: dispatch marshal through backend-neutral module calls
smarcd Apr 17, 2026
05c7cbf
refactor: dispatch function frontend access through backend types mod…
smarcd Apr 17, 2026
3573209
refactor: dispatch module frontend access through backend types modules
smarcd Apr 17, 2026
202dc6b
refactor: dispatch type frontend access through backend types modules
smarcd Apr 17, 2026
872ff43
refactor: dispatch float frontend access through backend types modules
smarcd Apr 17, 2026
d8ed25e
refactor: dispatch bool frontend access through backend types modules
smarcd Apr 17, 2026
cdf24da
refactor: dispatch mapping frontend access through backend types modules
smarcd Apr 17, 2026
bed4fff
refactor: dispatch sequence frontend access through backend types mod…
smarcd Apr 17, 2026
2c18bd9
refactor: dispatch type slot access through backend current macros
smarcd Apr 17, 2026
2be1949
refactor: dispatch opaque native type layouts through backend macros
smarcd Apr 17, 2026
548f816
refactor: dispatch PyAny frontend identity through backend types and …
smarcd Apr 17, 2026
12c56c3
refactor: dispatch exception layouts through backend current macros
smarcd Apr 17, 2026
4037ff0
refactor: dispatch pycell base dealloc through backend current macros
smarcd Apr 17, 2026
3ce97b5
refactor: centralize backend selection under backend module
smarcd Apr 17, 2026
85835f9
refactor: dispatch thread checker ownership through backend pyclass h…
smarcd Apr 17, 2026
5fcc0c9
refactor: route RustPython macro guards through backend helpers
smarcd Apr 17, 2026
2c271b0
refactor: dispatch frame frontend access through backend types modules
smarcd Apr 17, 2026
a59c035
refactor: rename RustPython sidecar hook to backend-neutral ffi API
smarcd Apr 17, 2026
ff6880d
refactor: move ffi backend routing behind backend macros
smarcd Apr 17, 2026
d51e996
fix: restore CPython abi3 backend routing
smarcd Apr 18, 2026
4d8be60
fix: harden RustPython runtime dispatch and buffer state
smarcd Apr 18, 2026
3901e01
ci: install windows gnu target before cross build
smarcd Apr 18, 2026
a4086a6
fix: restore ci compatibility after backend refactor
smarcd Apr 18, 2026
58983f6
ci: run guide docs on stable by default
smarcd Apr 18, 2026
87991d6
docs: fix stable rustdoc warnings after backend refactor
smarcd Apr 18, 2026
779dd26
fix: restore PyErr import for module gil_used
smarcd Apr 18, 2026
08deeef
fix: restore string test bytes trait import
smarcd Apr 18, 2026
194d8d8
ci: skip CodSpeed upload when token is unavailable
smarcd Apr 18, 2026
d58f6dd
ci: gate CodSpeed upload to upstream repo
smarcd Apr 18, 2026
0c306f2
fix: repair post-rebase backend exports and frame imports
smarcd Apr 18, 2026
6e39d1c
fix: adapt RustPython backend to upstream tip
smarcd Apr 18, 2026
b792254
ci: fix PR formatting and changelog follow-ups
smarcd Apr 18, 2026
7a7c211
style: apply rustfmt after backend refactor
smarcd Apr 18, 2026
e5623b4
style: finish CI rustfmt alignment
smarcd Apr 18, 2026
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
7 changes: 6 additions & 1 deletion .github/workflows/benches.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,14 @@ jobs:
with:
tool: cargo-codspeed

- name: Run the benchmarks
- name: Run the benchmarks with CodSpeed upload
if: ${{ github.repository == 'PyO3/pyo3' }}
uses: CodSpeedHQ/action@v4
with:
run: uvx nox -s codspeed
token: ${{ secrets.CODSPEED_TOKEN }}
mode: simulation

- name: Run the benchmarks without upload
if: ${{ github.repository != 'PyO3/pyo3' }}
run: uvx nox -s codspeed
10 changes: 9 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ parking_lot = { version = "0.12.3", features = ["arc_lock"] }
pyo3-build-config = { path = "pyo3-build-config", version = "=0.28.3", features = ["resolve-config"] }

[features]
default = ["macros"]
default = ["macros", "runtime-cpython"]

# Enables support for `async fn` for `#[pyfunction]` and `#[pymethods]`.
experimental-async = ["macros", "pyo3-macros/experimental-async"]
Expand All @@ -97,6 +97,13 @@ experimental-inspect = ["pyo3-macros/experimental-inspect"]
# Enables macros: #[pyclass], #[pymodule], #[pyfunction] etc.
macros = ["pyo3-macros"]

# Select the experimental RustPython runtime backend.
runtime-rustpython = ["pyo3-ffi/runtime-rustpython", "pyo3-build-config/runtime-rustpython"]

# Select the reference CPython-family runtime backend.
# This path remains responsible for existing CPython, PyPy, and GraalPy support.
runtime-cpython = []

# Enables multiple #[pymethods] per #[pyclass]
multiple-pymethods = ["inventory", "pyo3-macros/multiple-pymethods"]

Expand Down Expand Up @@ -175,6 +182,7 @@ full = [

[workspace]
members = [
"xtask",
"pyo3-ffi",
"pyo3-build-config",
"pyo3-macros",
Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -281,5 +281,3 @@ PyO3 is licensed under the [Apache-2.0 license](LICENSE-APACHE) or the [MIT lice
Python is licensed under the [Python License](https://docs.python.org/3/license.html).

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in PyO3 by you, as defined in the Apache License, shall be dual-licensed as above, without any additional terms or conditions.

[![Deploys by Netlify](https://www.netlify.com/assets/badges/netlify-badge-color-accent.svg)](https://www.netlify.com)
5 changes: 5 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ fn configure_pyo3() -> Result<()> {

fn main() {
pyo3_build_config::print_expected_cfgs();
if cargo_env_var("CARGO_FEATURE_RUNTIME_RUSTPYTHON").is_some() {
println!("cargo:rustc-cfg=PyRustPython");
print_feature_cfgs();
return;
}
if let Err(e) = configure_pyo3() {
eprintln!("error: {}", e.report());
std::process::exit(1)
Expand Down
1 change: 1 addition & 0 deletions newsfragments/5986.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add a compile-time RustPython backend with centralized backend dispatch.
6 changes: 6 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,10 @@ def test_cross_compilation_windows(session: nox.Session):
env = os.environ.copy()
env["XWIN_ARCH"] = "x86_64"

# The GNU cross-compilation lane uses plain `cargo build`, so the Rust
# standard library for that target must be installed explicitly.
_run(session, "rustup", "target", "add", "x86_64-pc-windows-gnu")

# abi3
_run_cargo(
session,
Expand Down Expand Up @@ -544,6 +548,8 @@ def docs(session: nox.Session, nightly: bool = False, internal: bool = False) ->
rustdoc_flags.append("--cfg docsrs")
toolchain_flags.append("+nightly")
cargo_flags.extend(["-Z", "unstable-options", "-Z", "rustdoc-scrape-examples"])
else:
toolchain_flags.append("+stable")

if internal:
rustdoc_flags.append("--Z unstable-options")
Expand Down
7 changes: 7 additions & 0 deletions proptest-regressions/conversions/std/num.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Seeds for failure cases proptest has generated in the past. It is
# automatically read and these particular cases re-run before any
# novel cases are generated.
#
# It is recommended to check this file in to source control so that
# everyone who runs the test benefits from these saved cases.
cc 1faf170d32151a6cc954f574a6081472e069907c79f8f59b877fec806b993866 # shrinks to x = 9223372036854775808
3 changes: 3 additions & 0 deletions pyo3-build-config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ default = []
# script. If this feature isn't enabled, the build script no-ops.
resolve-config = []

# Skip libpython/interpreter discovery and emit RustPython-specific cfgs.
runtime-rustpython = []

# deprecated
extension-module = []

Expand Down
7 changes: 7 additions & 0 deletions pyo3-build-config/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ fn generate_build_configs() -> Result<()> {
}

fn main() {
if std::env::var("CARGO_FEATURE_RUNTIME_RUSTPYTHON").is_ok() {
let _ = configure(None, "pyo3-build-config-file.txt");
let _ = configure(None, "pyo3-build-config.txt");
println!("cargo:rustc-cfg=PyRustPython");
return;
}

if std::env::var("CARGO_FEATURE_RESOLVE_CONFIG").is_ok() {
if let Err(e) = generate_build_configs() {
eprintln!("error: {}", e.report());
Expand Down
5 changes: 5 additions & 0 deletions pyo3-build-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ use target_lexicon::OperatingSystem;
/// | `#[cfg(PyPy)]` | This marks code which is run when compiling for PyPy. |
/// | `#[cfg(GraalPy)]` | This marks code which is run when compiling for GraalPy. |
///
/// These runtime distinctions remain part of the reference CPython-family backend in the
/// frontend/backend split. They are existing compatibility constraints, not a separate first
/// backend implementation.
///
/// For examples of how to use these attributes,
#[doc = concat!("[see PyO3's guide](https://pyo3.rs/v", env!("CARGO_PKG_VERSION"), "/building-and-distribution/multiple_python_versions.html)")]
/// .
Expand Down Expand Up @@ -261,6 +265,7 @@ pub fn print_expected_cfgs() {
println!("cargo:rustc-check-cfg=cfg(Py_GIL_DISABLED)");
println!("cargo:rustc-check-cfg=cfg(PyPy)");
println!("cargo:rustc-check-cfg=cfg(GraalPy)");
println!("cargo:rustc-check-cfg=cfg(PyRustPython)");
println!("cargo:rustc-check-cfg=cfg(py_sys_config, values(\"Py_DEBUG\", \"Py_REF_DEBUG\", \"Py_TRACE_REFS\", \"COUNT_ALLOCS\"))");
println!("cargo:rustc-check-cfg=cfg(pyo3_disable_reference_pool)");
println!("cargo:rustc-check-cfg=cfg(pyo3_leak_on_drop_without_reference_pool)");
Expand Down
9 changes: 9 additions & 0 deletions pyo3-ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,20 @@ rust-version.workspace = true

[dependencies]
libc = "0.2.62"
rustpython = { git = "https://github.com/RustPython/RustPython", rev = "b80c2bd5ecedacc23a04c28e5f6dcb82b5616e88", optional = true }
rustpython-vm = { git = "https://github.com/RustPython/RustPython", rev = "b80c2bd5ecedacc23a04c28e5f6dcb82b5616e88", optional = true }

[features]

default = []

# Build the ffi crate without libpython discovery/linking for the RustPython backend.
runtime-rustpython = [
"dep:rustpython",
"dep:rustpython-vm",
"pyo3-build-config/runtime-rustpython",
]

# deprecated
extension-module = ["pyo3-build-config/extension-module"]

Expand Down
5 changes: 5 additions & 0 deletions pyo3-ffi/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,11 @@ fn print_config_and_exit(config: &InterpreterConfig) {

fn main() {
pyo3_build_config::print_expected_cfgs();
if std::env::var("CARGO_FEATURE_RUNTIME_RUSTPYTHON").is_ok() {
println!("cargo:rustc-cfg=PyRustPython");
print_feature_cfgs();
return;
}
if let Err(e) = configure_pyo3() {
eprintln!("error: {}", e.report());
std::process::exit(1)
Expand Down
Loading
Loading