-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Add minimal C-api implementation that builds with Pyo3 #7562
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
Draft
bschoenmaeckers
wants to merge
211
commits into
RustPython:main
Choose a base branch
from
bschoenmaeckers:c-api
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 1 commit
Commits
Show all changes
211 commits
Select commit
Hold shift + click to select a range
14021a7
export c api
bschoenmaeckers db17f41
type mapping v1
bschoenmaeckers 0855a91
Type mapping v2
bschoenmaeckers 3e3947e
Implement type flags
bschoenmaeckers 0a68d35
Implement `PyUnicode_FromStringAndSize`
bschoenmaeckers 0d9c033
Do not use `C-unwind`
bschoenmaeckers 030fce9
implement `PyLong_AsLong`
bschoenmaeckers d5e66d0
Add `with_vm` helper
bschoenmaeckers 7062bd2
Move `PyThreadState` to `pystate.rs`
bschoenmaeckers ba980c6
Basic multi-threading support
bschoenmaeckers f3def84
Cleanup
bschoenmaeckers e89d0b5
Attach thread in `Py_InitializeEx`
bschoenmaeckers e599708
Map RustPython type flags to CPython type flags
bschoenmaeckers 33901cf
Use `*const Py<PyType>` instead of `*mut PyTypeObject`
bschoenmaeckers c17c8e7
Implement `PyUnicode_AsUTF8AndSize`
bschoenmaeckers 39f4e24
Implement `PyType_GetName`
bschoenmaeckers 19eaccf
Implement alternative `PyLong` constructors
bschoenmaeckers e01bb90
Move `init_static_type_pointers` to `pylifecycle.rs`
bschoenmaeckers 14a41e6
Add support for `None`, `True`, `False`, `Ellipsis` & `NotImplemented`
bschoenmaeckers 24b4bb2
Add support for PyBytes
bschoenmaeckers 5fa14a0
Add basic exception support
bschoenmaeckers bee34dd
Add import support
bschoenmaeckers f4a091d
Add basic call support
bschoenmaeckers 93ca2ba
Use pyo3 as test harness
bschoenmaeckers 7f7e9e4
Fix pyo3 by correctly setting `PYO3_CONFIG_FILE`
bschoenmaeckers 26524f2
Fix python bool creation test
bschoenmaeckers 54c7aa3
Implement `PyUnicode_EqualToUTF8AndSize`
bschoenmaeckers ae21329
Add `PyExc_SystemError`
bschoenmaeckers fe5279b
Compile to dynamic lib
bschoenmaeckers 78858ac
Add test for static type pointers
bschoenmaeckers 1a2f0b7
Streamline returning PyResult
bschoenmaeckers 96ccb16
Fix some clippy warning
bschoenmaeckers 4a5427b
Use bounded channel for vm request response
bschoenmaeckers fb1677d
Test creating a new (heap) exception type
bschoenmaeckers 392528c
Don't check for NULL in `Py_DecRef`/`Py_IncRef`
bschoenmaeckers 778a17b
Add basic `PyDict` support
bschoenmaeckers 6c7139e
Implement minimal tuple functions
bschoenmaeckers 7906689
Implement `PyObject_Repr` & `PyObject_Str`
bschoenmaeckers 9bfe89f
Implement `PyObject_GetAttr`
bschoenmaeckers 1e21870
Implement `PyUnicode_InternInPlace`
bschoenmaeckers 5592515
Add support for running python source code
bschoenmaeckers a233441
Make all modules private
bschoenmaeckers da7f460
Merge remote-tracking branch 'origin/main' into c-api
bschoenmaeckers e815b12
Implement `PyErr_SetString`
bschoenmaeckers f58b9da
Add basic support for `PyList`
bschoenmaeckers 755e2f2
Support `PyLong_AsLong` for non `PyInt` types
bschoenmaeckers 176e833
Add support for `PyComplex`
bschoenmaeckers 26efedc
Implement c_variadic `PyObject_CallMethodObjArgs`
bschoenmaeckers e000cca
Implement `PyCapsule`
bschoenmaeckers a494a1c
Allow creating empty tuples
bschoenmaeckers 0eada9b
Implement `PyCMethod_New`
bschoenmaeckers f97275c
Add `PyMethodPointer` union
bschoenmaeckers 58c1fb1
Also support `NoArgs` CFunction's
bschoenmaeckers dbb9e00
Fix error return of `PyCFunction`
bschoenmaeckers 6e70a3e
Add `PyDict` iter support
bschoenmaeckers e7f9825
Add more `Exception` type statics
bschoenmaeckers 79220ac
Add support for `set`, `get`, & `del` on any object
bschoenmaeckers bc0aa87
Merge remote-tracking branch 'origin/main' into c-api
bschoenmaeckers 0ea2c3f
Refactor `FfiResult`
bschoenmaeckers 505dc8d
Fix unset exception types
bschoenmaeckers a74e069
Add `PyBaseObject_Type` static
bschoenmaeckers 14ed761
Add `PyObject_SetAttr`
bschoenmaeckers 2aab0d1
Add `PyObject_GenericGetDict` & `PyObject_GenericSetDict`
bschoenmaeckers ce76108
Fix some clippy warning
bschoenmaeckers bbe3432
Merge branch 'main' into c-api
bschoenmaeckers 7601af3
Add `PyObject_SetAttrString`
bschoenmaeckers e874e00
Add `PyObject_GC_UnTrack`
bschoenmaeckers 41514e8
Implement `Py_IS_TYPE`
bschoenmaeckers d927aa7
Add all exception statics
bschoenmaeckers 456189a
Implement `PyObject_Vectorcall`
bschoenmaeckers 1b5f2dc
Add `PyObject_GetAttrString`
bschoenmaeckers 6826831
Use custom RustPython build of `PyO3`
bschoenmaeckers 7c058e7
Add basic support for new classes
bschoenmaeckers db1806d
Add support for class attributes
bschoenmaeckers badf780
Add basic support for PyO3 class methods
bschoenmaeckers 1859604
Merge remote-tracking branch 'origin/main' into c-api
bschoenmaeckers a2aa14c
Add `PyTuple_FromArray` & `PyTuple_Pack`
bschoenmaeckers dee9ef5
Add `PyFloat` support
bschoenmaeckers 4cb55aa
Add `Py_NewRef`
bschoenmaeckers 53925bf
Add `PyLong_AsUnsignedLongLong`
bschoenmaeckers 9da2197
Add `PyNumber_Index`
bschoenmaeckers aac1055
Fix float test
bschoenmaeckers 0121fce
Implement `PyTraceBack_Print`
bschoenmaeckers aff7bc8
Implement `PyUnicode_AsEncodedString`
bschoenmaeckers df58443
Merge remote-tracking branch 'origin/main' into c-api
bschoenmaeckers 5200094
Merge branch 'main' into c-api
bschoenmaeckers 86c38de
Add `PyList_Append`
bschoenmaeckers 0a7739c
Add type check functions
bschoenmaeckers 57687e1
Add `PyObject_Call`
bschoenmaeckers 1d9d0e7
Add support for `FASTCALL`/`STATIC`/`CLASS` c functions
bschoenmaeckers ed321ba
Add module definition support
bschoenmaeckers f6b9c69
Implement `PyTuple_GetSlice`
bschoenmaeckers 7da03f1
Merge remote-tracking branch 'origin/main' into c-api
bschoenmaeckers f33b2e0
Implement `Py_GetVersion`
bschoenmaeckers 82979e2
Implement `PyCapsule_IsValid`
bschoenmaeckers 1b01eaa
Refactor c function trampolines
bschoenmaeckers 32d2d1e
Implement `PyList_Insert`
bschoenmaeckers 1582081
Implement `PyList_Reverse`
bschoenmaeckers b180a49
Allow `PyBytes_FromStringAndSize` with uninitialized bytes
bschoenmaeckers bb44774
Merge remote-tracking branch 'origin/main' into c-api
bschoenmaeckers 1d7753b
Add basic capi error support
bschoenmaeckers a47ad11
Add missing symbols to make tests compile again
bschoenmaeckers 782771d
Add `pyerrors` to dictionary
bschoenmaeckers b2ef549
Return exception in `Py_GetConstantBorrowed`
bschoenmaeckers a102ebe
Remove `allow(dead_code)`
bschoenmaeckers 654e4dc
Fix windows
bschoenmaeckers ec04022
Load stdlib when calling `Py_InitializeEx`
bschoenmaeckers ca0db02
Debug tests
bschoenmaeckers 9b54723
Revert "Load stdlib when calling `Py_InitializeEx`"
bschoenmaeckers d96aa9e
Disable tests on windows for now
bschoenmaeckers d3c3d0c
Truncate `PyType_GetFlags` to be always 32 bits
bschoenmaeckers 37b96c6
Add test for exception type checking
bschoenmaeckers 6bfc1a9
Remove subclass type flags
bschoenmaeckers 5bbe3d9
Update PyO3 to main branch
bschoenmaeckers 4222f56
Add type check functions
bschoenmaeckers e616e24
Add bool object functions
bschoenmaeckers cf95b66
Add exact type check macros
bschoenmaeckers af687b1
Implement `PyExceptionClass_Check`
bschoenmaeckers 0c1481f
Add self support to `PyNativeFunction`
bschoenmaeckers f05f2cb
Merge remote-tracking branch 'origin/main' into capi-errors
bschoenmaeckers 3a93e5c
Use latest pyo3 to make test work on windows
bschoenmaeckers f44b143
Revert "Use latest pyo3 to make test work on windows"
bschoenmaeckers 2d49dc9
Merge branch 'capi-errors' into c-api
bschoenmaeckers bf0f2c1
Add todo list
bschoenmaeckers e4fd4e6
Update var_arg functions
bschoenmaeckers a9ef78c
Fix `ctypes.py_object` handling
bschoenmaeckers d285db6
Merge remote-tracking branch 'origin/main' into c-api
bschoenmaeckers 15673d6
Refactor `build_method_def`
bschoenmaeckers 287d4a3
Implement `build_method_def` for `METH_O`
bschoenmaeckers a38acf7
Extract callable convertions from `build_method_def`
bschoenmaeckers 915995f
Make PyMethodDef members public
bschoenmaeckers 306aaaf
Add `PyCFunction_New` & `PyCFunction_NewEx`
bschoenmaeckers a2987e2
Fix self handling in `METH_NOARGS` functions
bschoenmaeckers 967a4ee
Fix handling of self in `METH_O` functions
bschoenmaeckers cee18f6
Implement `PyObject_IsSubclass` & `PyObject_IsInstance`
bschoenmaeckers c316e31
Merge remote-tracking branch 'origin/main' into c-api
bschoenmaeckers 91fdab5
Discard `self` on static functions
bschoenmaeckers 3d6d32f
Merge branch 'main' into c-api
bschoenmaeckers 7ff3290
Merge branch 'main' into c-api
bschoenmaeckers 5ca97d3
Merge branch 'main' into c-api
bschoenmaeckers 442107f
Fix `Py_GetVersion`
bschoenmaeckers 05851f0
Merge remote-tracking branch 'origin/main' into c-api
bschoenmaeckers 43c9c37
Rename `pycapsule`
bschoenmaeckers 3b1c032
Implement remaining capsule functions
bschoenmaeckers b811067
Merge remote-tracking branch 'origin/main' into c-api
bschoenmaeckers a584491
Merge remote-tracking branch 'origin/main' into c-api
bschoenmaeckers 1395435
Update todo list
bschoenmaeckers 250614c
Merge remote-tracking branch 'origin/main' into c-api
bschoenmaeckers 74b1d6b
Merge remote-tracking branch 'origin/main' into c-api
bschoenmaeckers 4fd3f11
Merge branch 'main' into c-api
bschoenmaeckers 141bc0f
Update pyo3
bschoenmaeckers 7063c0b
Merge remote-tracking branch 'origin/main' into c-api
bschoenmaeckers 2ee6678
Implement `PyDict_SetDefaultRef`
bschoenmaeckers 4d02833
Merge remote-tracking branch 'origin/main' into c-api
bschoenmaeckers 1a9338e
Add agent skill
bschoenmaeckers bf341fd
Add `set` object functions to c-api
bschoenmaeckers d181a00
Add mapping c-api functions
bschoenmaeckers 577922f
Add number protocol functions
bschoenmaeckers 8b1a9f5
Merge remote-tracking branch 'origin/main' into c-api
bschoenmaeckers bf5d210
Merge remote-tracking branch 'origin/main' into c-api
bschoenmaeckers bdf5eb6
Merge branch 'main' into c-api
bschoenmaeckers 2a99072
Merge remote-tracking branch 'origin/main' into c-api
bschoenmaeckers 5dd3361
Update todo list
bschoenmaeckers cd1496d
Merge remote-tracking branch 'origin/main' into c-api
bschoenmaeckers dfaff5f
Update todo list
bschoenmaeckers 70ec806
Add PySlot support
bschoenmaeckers 0cf6660
Merge branch 'main' into c-api
bschoenmaeckers 990ae32
Use PyO3 main & enable c-api tests
bschoenmaeckers 7408597
Enable `abi3t` support in PyO3
bschoenmaeckers ee95e8d
Add left over c-api functions
bschoenmaeckers 5d5d7ba
Fix PyLong_AsUnsignedLongLongMask
bschoenmaeckers bdc9310
Update pyo3 to `0.29`
bschoenmaeckers 793d41a
Add `PyInt::as_u64_mask`
bschoenmaeckers 05c036c
Fix `PyInt::as_u32_mask`
bschoenmaeckers 65e3909
Merge branch 'c-api-misc-tests' into c-api
bschoenmaeckers 26a81ef
Disable type creation api's
bschoenmaeckers cf87b8e
Implement `PyModule_FromSlotsAndSpec` & `PyModule_Exec`
bschoenmaeckers 7cfcc6f
Recover new type test
bschoenmaeckers 8132f21
Merge remote-tracking branch 'origin/main' into c-api
bschoenmaeckers 30ad20c
Merge branch 'main' into c-api
bschoenmaeckers 803c58c
Move type c-api functions
bschoenmaeckers cfdbfe6
Merge branch 'c-api-move-type' into c-api
bschoenmaeckers b6c8ce3
Add basic type creation support
bschoenmaeckers b770fde
Merge remote-tracking branch 'origin/main' into c-api
bschoenmaeckers 0c9653e
Add slot iters
bschoenmaeckers 7ccf413
Split PySlotKind into 2 variants
bschoenmaeckers 19670d3
Cleanup slots
bschoenmaeckers e6424e2
Fix clippy warnings in tests
bschoenmaeckers 5942ae4
Cleanup slots
bschoenmaeckers 10b6200
Merge branch 'main' into c-api
bschoenmaeckers aac510b
Merge branch 'main' into c-api
bschoenmaeckers b1da12b
Add support for members and descriptors to types
bschoenmaeckers bcdd0cd
Convert PySlot pointers into ref's
bschoenmaeckers e5978fc
Merge remote-tracking branch 'origin/main' into c-api
bschoenmaeckers 1060c5f
Merge branch 'main' into c-api
bschoenmaeckers ee7d9c3
Merge branch 'main' into c-api
bschoenmaeckers 8d9965c
Merge branch 'main' into c-api
bschoenmaeckers 16650f9
Merge branch 'main' into c-api
bschoenmaeckers 3fc0306
Merge branch 'main' into c-api
bschoenmaeckers 42fad2c
Merge remote-tracking branch 'origin/main' into c-api
bschoenmaeckers 4b642b2
Merge branch 'main' into c-api
bschoenmaeckers f60a8e5
Add c trampiline cache for tp_new
bschoenmaeckers dde6189
Merge branch 'main' into c-api
bschoenmaeckers a3b5a2e
Merge remote-tracking branch 'origin/main' into c-api
bschoenmaeckers 0510f3c
Merge remote-tracking branch 'origin/main' into c-api
bschoenmaeckers 89d2d74
Merge branch 'main' into c-api
bschoenmaeckers e68ed84
Merge remote-tracking branch 'origin/main' into c-api
bschoenmaeckers 2755f1b
Check own size in PyObject_GetTypeData
bschoenmaeckers 435a2f5
Update pyo3
bschoenmaeckers 065f38f
Add subclass test
bschoenmaeckers f252849
Merge branch 'main' into c-api
bschoenmaeckers File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add
with_vm helper
- Loading branch information
commit d5e66d0d833f1df93da770c1d83e9f3d82ea3209
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.