Skip to content

Fix compatibility with Python 3.13 and Cython 3#69

Merged
wridgers merged 21 commits intoantocuni:masterfrom
dmrlawson:davidlaw_updates_2
Jun 9, 2025
Merged

Fix compatibility with Python 3.13 and Cython 3#69
wridgers merged 21 commits intoantocuni:masterfrom
dmrlawson:davidlaw_updates_2

Conversation

@dmrlawson
Copy link
Copy Markdown
Collaborator

Python 3.13 requires Cython 3. Capnpy currently doesn't work with Cython 3 and so can't be used with Python 3.13.

This PR attempts to fix Cython 3 compatibility.

The main code issue was that the Cython version of BaseEnum inherited from int. This is no longer allowed in Cython 3.

I'm not very familiar withe Cython, so this quick fix attempts to use the Python version of BaseEnum which was previously only used for Pypy.

David Lawson added 6 commits January 15, 2025 08:18
Without this change cython produces incorrect C code with kwargs that start but don't end with `__`.
This causes issues on Cython 3 because we're no longer allowed to inherit from `int`. The fix here is to use the Python version of BaseEnum on both cPython and Pypy which will presumably be slower.
@dmrlawson dmrlawson force-pushed the davidlaw_updates_2 branch from f43f8a1 to 8cb79df Compare May 30, 2025 10:28
Comment thread capnpy/compiler/module.py Outdated
@dmrlawson
Copy link
Copy Markdown
Collaborator Author

For the hashing stuff: I think the hashing functions were previously private (the names start with _) and were moved to the internal API starting with 3.13.

Numpy had complaints about this (e.g. python/cpython#111545) and I think ultimately just copied the cpython code into numpy. We could do the same here.

@dmrlawson dmrlawson force-pushed the davidlaw_updates_2 branch 4 times, most recently from db36eac to 6e60835 Compare June 6, 2025 11:22
@antocuni
Copy link
Copy Markdown
Owner

antocuni commented Jun 6, 2025

Thank you for the PR.
However, I don't have bandwidth to review this, and capnpy is de facto unmaintained on my side.
I'll be happy to add you as a maintainer if it helps.

@dmrlawson dmrlawson marked this pull request as draft June 9, 2025 07:48
@dmrlawson
Copy link
Copy Markdown
Collaborator Author

Marking as draft while I redo the _hash change.

@dmrlawson
Copy link
Copy Markdown
Collaborator Author

Thank you for the PR. However, I don't have bandwidth to review this, and capnpy is de facto unmaintained on my side. I'll be happy to add you as a maintainer if it helps.

Thank you. I've been coordinating with @wridgers to get the tests running and do a deployment so it's not critical, though it could come in useful.

@dmrlawson dmrlawson force-pushed the davidlaw_updates_2 branch from ec9767f to 28ee71b Compare June 9, 2025 09:24
David Lawson and others added 7 commits June 9, 2025 10:27
_Py_HashBytes was hidden in 3.13 (python/cpython#107026).

> C assumes that any function with an "implicit declaration" returns an int, which'll be smaller than a Py_hash_t, hence the different results. (https://groups.google.com/g/cython-users/c/YQkU8oc8oSM/m/nVJ_IX8KAgAJ)
Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 2 to 4.1.7.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](actions/download-artifact@v2...v4.1.7)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
David Lawson added 3 commits June 9, 2025 10:27
The previous version was failing in Python 3.13, 4.26 isn't compatible with 3.8
@dmrlawson dmrlawson force-pushed the davidlaw_updates_2 branch from 28ee71b to b0ca17f Compare June 9, 2025 09:27
@dmrlawson dmrlawson marked this pull request as ready for review June 9, 2025 10:26
@wridgers wridgers merged commit 2b7bf0d into antocuni:master Jun 9, 2025
7 checks passed
@wridgers
Copy link
Copy Markdown
Collaborator

wridgers commented Jun 9, 2025

Let's try a RC of this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants