ENH: Implement opaque PyObject ABI support #31091
Conversation
|
Sorry for adding and removing the milestone repeatedly. I know we talked about this yesterday at the meeting, but it occurs to me that maybe it's reasonable for NumPy 2.5 to support Python 3.15, e.g. by uploading wheels to PyPI? If so, it would be logical to include this as well. NumPy 2.5 is scheduled to be released this summer, after the ABI for Python 3.15 is frozen, so it should be perfectly fine to build and upload NumPy wheels using a CPython beta. I know that has implications for the release workflow, so ping @rgommers. |
|
We don't upload wheels to PyPI for new Python releases until the rc release and cibuildwheel support for it. EDIT: it is fine to build the wheels, just not to upload them. For instance, we build wheels for pyodide, but we don't upload them. |
ngoldbaum
left a comment
There was a problem hiding this comment.
I asked Claude to review this PR. I unfortunately don't have the mental patience to actually read this whole diff in one sitting.
It spotted a couple subtle issues in the iterator macros on the opaque pyobject build. Up to you, but I think it might be worth adding tests for the C iterator APIs under the opaque pyobject builds given the complexity of these macros.
But maybe also check for open-source uses first by searching github for items in the C API to see if it's worth doing.
What Chuck said - only after 3.15.0rc1. There's nothing in this PR that requires this though, and there's no problem merging this PR and having support in the headers in 2.5.0. |
seberg
left a comment
There was a problem hiding this comment.
Didn't scan too closely for bugs, but I think Nathan got them (and honestly, I am not all that worried because all of these look like they should be compile time errors downstream and then even a minor release can fix them when they come up -- doesn't mean it isn't better to do it now :)).
Overall, the diff seems much more churn than it actually is, IMO, so this should be fast to wrap up.
ngoldbaum
left a comment
There was a problem hiding this comment.
I asked Claude to give it another once-over and spotted a couple more issues.
I also tried building this branch against Pandas and saw compilation errors. We'll need to fix those before this can be merged.
|
I added We have zero narrative docs about how to use the NumPy C API with the Python limited API. I'm going to open a new issue tracking that and we can describe abi3t builds there. |
ngoldbaum
left a comment
There was a problem hiding this comment.
I’m planning to merge this next week, let me know if anyone else wants a chance to review.
|
3.15b1 is coming soon and I'd like to enable downstream testing of this, so I'm going to merge this. |
|
|
|
Sorry for the overly hasty merge. It probably needs to be updated for 3.15.0b1, feel free to merge a commit disabling the test and either me or Kumar will send in a fix soon. |
|
Created #31403 for fixing it |
PR summary
This PR adds support for building opaque PyObject stable ABI extensions using NumPy.
AI Disclosure
Claude was used to generate the tests.