Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
54156f6
export c api
bschoenmaeckers Apr 4, 2026
2250a1c
type mapping v1
bschoenmaeckers Apr 5, 2026
bc96211
Type mapping v2
bschoenmaeckers Apr 5, 2026
46307f6
Implement type flags
bschoenmaeckers Apr 5, 2026
b08d41a
Implement `PyUnicode_FromStringAndSize`
bschoenmaeckers Apr 5, 2026
34c13f4
Do not use `C-unwind`
bschoenmaeckers Apr 5, 2026
24b2c63
implement `PyLong_AsLong`
bschoenmaeckers Apr 5, 2026
384b378
Add `with_vm` helper
bschoenmaeckers Apr 5, 2026
f49e859
Move `PyThreadState` to `pystate.rs`
bschoenmaeckers Apr 5, 2026
e18eef7
Basic multi-threading support
bschoenmaeckers Apr 5, 2026
565bf5e
Cleanup
bschoenmaeckers Apr 5, 2026
85b2928
Attach thread in `Py_InitializeEx`
bschoenmaeckers Apr 5, 2026
c603d37
Map RustPython type flags to CPython type flags
bschoenmaeckers Apr 7, 2026
cee9403
Use `*const Py<PyType>` instead of `*mut PyTypeObject`
bschoenmaeckers Apr 7, 2026
0a50fcc
Implement `PyUnicode_AsUTF8AndSize`
bschoenmaeckers Apr 7, 2026
f588979
Implement `PyType_GetName`
bschoenmaeckers Apr 7, 2026
edaca0c
Implement alternative `PyLong` constructors
bschoenmaeckers Apr 7, 2026
e4c8bd7
Move `init_static_type_pointers` to `pylifecycle.rs`
bschoenmaeckers Apr 7, 2026
26c2777
Add support for `None`, `True`, `False`, `Ellipsis` & `NotImplemented`
bschoenmaeckers Apr 7, 2026
09466e2
Add support for PyBytes
bschoenmaeckers Apr 8, 2026
94cc39b
Add basic exception support
bschoenmaeckers Apr 8, 2026
2ef64d2
Add import support
bschoenmaeckers Apr 8, 2026
55b1e14
Add basic call support
bschoenmaeckers Apr 8, 2026
2a7a82e
Use pyo3 as test harness
bschoenmaeckers Apr 8, 2026
96e16b1
Fix pyo3 by correctly setting `PYO3_CONFIG_FILE`
bschoenmaeckers Apr 9, 2026
e351fb2
Fix python bool creation test
bschoenmaeckers Apr 9, 2026
2fece20
Implement `PyUnicode_EqualToUTF8AndSize`
bschoenmaeckers Apr 9, 2026
e56029d
Add `PyExc_SystemError`
bschoenmaeckers Apr 9, 2026
9702a47
Compile to dynamic lib
bschoenmaeckers Apr 9, 2026
738d4d4
Add test for static type pointers
bschoenmaeckers Apr 9, 2026
8ad7e0c
Streamline returning PyResult
bschoenmaeckers Apr 9, 2026
32faf14
Fix some clippy warning
bschoenmaeckers Apr 9, 2026
a34ced9
Use bounded channel for vm request response
bschoenmaeckers Apr 9, 2026
5a8c57b
Test creating a new (heap) exception type
bschoenmaeckers Apr 9, 2026
3dda576
Don't check for NULL in `Py_DecRef`/`Py_IncRef`
bschoenmaeckers Apr 9, 2026
a1b3af6
Add basic `PyDict` support
bschoenmaeckers Apr 9, 2026
3c7ef8f
Implement minimal tuple functions
bschoenmaeckers Apr 9, 2026
5625ba3
Implement `PyObject_Repr` & `PyObject_Str`
bschoenmaeckers Apr 9, 2026
ea45d78
Implement `PyObject_GetAttr`
bschoenmaeckers Apr 9, 2026
fcbc6b9
Implement `PyUnicode_InternInPlace`
bschoenmaeckers Apr 9, 2026
ff9d385
Add support for running python source code
bschoenmaeckers Apr 10, 2026
7b36240
Make all modules private
bschoenmaeckers Apr 10, 2026
8805658
Merge remote-tracking branch 'origin/main' into c-api
bschoenmaeckers Apr 10, 2026
c4b8ea3
Implement `PyErr_SetString`
bschoenmaeckers Apr 10, 2026
dc56590
Add basic support for `PyList`
bschoenmaeckers Apr 10, 2026
47ed41d
Support `PyLong_AsLong` for non `PyInt` types
bschoenmaeckers Apr 10, 2026
375a170
Add support for `PyComplex`
bschoenmaeckers Apr 10, 2026
fe8107a
Implement c_variadic `PyObject_CallMethodObjArgs`
bschoenmaeckers Apr 10, 2026
2f6fc50
Implement `PyCapsule`
bschoenmaeckers Apr 11, 2026
52442ae
Allow creating empty tuples
bschoenmaeckers Apr 11, 2026
537fc69
Implement `PyCMethod_New`
bschoenmaeckers Apr 11, 2026
62485f6
Add `PyMethodPointer` union
bschoenmaeckers Apr 11, 2026
61de6bf
Also support `NoArgs` CFunction's
bschoenmaeckers Apr 11, 2026
248ea52
Fix error return of `PyCFunction`
bschoenmaeckers Apr 11, 2026
ad0d1af
Add `PyDict` iter support
bschoenmaeckers Apr 11, 2026
d81ad21
Add more `Exception` type statics
bschoenmaeckers Apr 11, 2026
6cd7fc9
Add support for `set`, `get`, & `del` on any object
bschoenmaeckers Apr 13, 2026
d228a78
Merge remote-tracking branch 'origin/main' into c-api
bschoenmaeckers Apr 13, 2026
ae3f3db
Refactor `FfiResult`
bschoenmaeckers Apr 13, 2026
4d23f7c
Fix unset exception types
bschoenmaeckers Apr 13, 2026
56f3823
Add `PyBaseObject_Type` static
bschoenmaeckers Apr 13, 2026
4f6798a
Add `PyObject_SetAttr`
bschoenmaeckers Apr 13, 2026
685c4b7
Add `PyObject_GenericGetDict` & `PyObject_GenericSetDict`
bschoenmaeckers Apr 13, 2026
ac50f2b
Fix some clippy warning
bschoenmaeckers Apr 13, 2026
16e1193
Merge branch 'main' into c-api
bschoenmaeckers Apr 14, 2026
9e931f7
Add `PyObject_SetAttrString`
bschoenmaeckers Apr 14, 2026
384e15e
Add `PyObject_GC_UnTrack`
bschoenmaeckers Apr 14, 2026
09aab0a
Implement `Py_IS_TYPE`
bschoenmaeckers Apr 15, 2026
7ee1e27
Add all exception statics
bschoenmaeckers Apr 16, 2026
661e7bd
Implement `PyObject_Vectorcall`
bschoenmaeckers Apr 16, 2026
65c80c8
Add `PyObject_GetAttrString`
bschoenmaeckers Apr 16, 2026
d2c2c63
Use custom RustPython build of `PyO3`
bschoenmaeckers Apr 17, 2026
b4bc0d8
Add basic support for new classes
bschoenmaeckers Apr 17, 2026
2dc9a82
Add support for class attributes
bschoenmaeckers Apr 17, 2026
e790f34
Add ABI facade support for pristine PyO3 packages
smarcd Apr 19, 2026
975ba00
cleanup: drop debug tracing and local pyo3 paths
smarcd Apr 21, 2026
f67a934
cleanup: remove static symbol facade
smarcd Apr 21, 2026
2f3d458
fix: resolve vectorcall and method call abi issues
smarcd Apr 21, 2026
2c6add3
Improve ABI facade compatibility for pristine PyO3 packages
smarcd Apr 22, 2026
43d6908
chore: snapshot validated ABI facade prototype state
smarcd Apr 22, 2026
a7a9825
fix: resolve vectorcall kwargs and duplicate method-call export
smarcd Apr 22, 2026
b833ae2
fix: retain C method-call shim export
smarcd Apr 22, 2026
5b03e10
docs: record ABI facade verification status
smarcd Apr 22, 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
14 changes: 14 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ tkinter = ["rustpython-stdlib/tkinter"]
winresource = "0.1"

[dependencies]
rustpython-capi = { path = "crates/capi" }
rustpython-compiler = { workspace = true }
rustpython-pylib = { workspace = true, optional = true }
rustpython-stdlib = { workspace = true, optional = true, features = ["compiler"] }
Expand All @@ -53,7 +54,7 @@ rustyline = { workspace = true }

[dev-dependencies]
criterion = { workspace = true }
pyo3 = { version = "0.28.2", features = ["auto-initialize"] }
pyo3 = { version = "0.28.3", features = ["auto-initialize"] }
rustpython-stdlib = { workspace = true }
ruff_python_parser = { workspace = true }

Expand Down
35 changes: 35 additions & 0 deletions Lib/collections/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,24 @@

__all__ = [
'ChainMap',
'Collection',
'Container',
'Counter',
'Callable',
'Iterable',
'Iterator',
'ItemsView',
'KeysView',
'OrderedDict',
'Mapping',
'MappingView',
'MutableMapping',
'MutableSet',
'Reversible',
'Sequence',
'Set',
'Sized',
'ValuesView',
'UserDict',
'UserList',
'UserString',
Expand All @@ -32,6 +48,25 @@
_sys.modules['collections.abc'] = _collections_abc
abc = _collections_abc

# Compatibility aliases for packages which still import ABCs from
# `collections` instead of `collections.abc`.
Collection = _collections_abc.Collection
Container = _collections_abc.Container
Callable = _collections_abc.Callable
Iterable = _collections_abc.Iterable
Iterator = _collections_abc.Iterator
ItemsView = _collections_abc.ItemsView
KeysView = _collections_abc.KeysView
Mapping = _collections_abc.Mapping
MappingView = _collections_abc.MappingView
MutableMapping = _collections_abc.MutableMapping
MutableSet = _collections_abc.MutableSet
Reversible = _collections_abc.Reversible
Sequence = _collections_abc.Sequence
Set = _collections_abc.Set
Sized = _collections_abc.Sized
ValuesView = _collections_abc.ValuesView

from itertools import chain as _chain
from itertools import repeat as _repeat
from itertools import starmap as _starmap
Expand Down
8 changes: 7 additions & 1 deletion build.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
fn main() {
if std::env::var("CARGO_CFG_TARGET_OS").unwrap() == "windows" {
let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap();

if target_os != "windows" {
println!("cargo:rustc-link-arg-bin=rustpython=-Wl,-export_dynamic");
}

if target_os == "windows" {
println!("cargo:rerun-if-changed=logo.ico");
let mut res = winresource::WindowsResource::new();
if std::path::Path::new("logo.ico").exists() {
Expand Down
3 changes: 3 additions & 0 deletions crates/capi/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[env]
PYO3_CONFIG_FILE = { value = "pyo3-rustpython.config", relative = true }
PYO3_NO_PYTHON = { value = "1" }
25 changes: 25 additions & 0 deletions crates/capi/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[package]
name = "rustpython-capi"
description = "Minimal CPython C-API compatibility exports for RustPython"
version.workspace = true
authors.workspace = true
edition.workspace = true
rust-version.workspace = true
repository.workspace = true
license.workspace = true

[dependencies]
bitflags.workspace = true
libc.workspace = true
libloading = "0.9"
num-complex.workspace = true
rustpython-vm = { workspace = true, features = ["threading", "compiler"]}

[build-dependencies]
cc = "1"

[dev-dependencies]
pyo3 = { version = "0.28.3", features = ["auto-initialize", "abi3"] }

[lints]
workspace = true
6 changes: 6 additions & 0 deletions crates/capi/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
fn main() {
println!("cargo:rerun-if-changed=csrc/pyobject_callmethodobjargs.c");
cc::Build::new()
.file("csrc/pyobject_callmethodobjargs.c")
.compile("rustpython_capi_shims");
}
45 changes: 45 additions & 0 deletions crates/capi/csrc/pyobject_callmethodobjargs.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#include <stdarg.h>
#include <stddef.h>
#include <stdlib.h>

typedef struct _object PyObject;

extern PyObject *RustPython_PyObject_CallMethodObjArgsArray(
PyObject *receiver,
PyObject *name,
PyObject *const *args,
size_t nargs
);

PyObject *PyObject_CallMethodObjArgs(PyObject *receiver, PyObject *name, ...) {
va_list ap;
size_t nargs = 0;

va_start(ap, name);
while (va_arg(ap, PyObject *) != NULL) {
nargs++;
}
va_end(ap);

PyObject **args = NULL;
if (nargs > 0) {
args = (PyObject **)malloc(sizeof(PyObject *) * nargs);
if (args == NULL) {
return NULL;
}
va_start(ap, name);
for (size_t i = 0; i < nargs; i++) {
args[i] = va_arg(ap, PyObject *);
}
(void)va_arg(ap, PyObject *);
va_end(ap);
}

PyObject *result = RustPython_PyObject_CallMethodObjArgsArray(receiver, name, args, nargs);
free(args);
return result;
}

void *RustPython_Keep_PyObject_CallMethodObjArgs(void) {
return (void *)&PyObject_CallMethodObjArgs;
}
6 changes: 6 additions & 0 deletions crates/capi/pyo3-rustpython.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
implementation=RustPython
version=3.14
shared=true
abi3=true
build_flags=
suppress_build_script_link_lines=true
Loading