crate-py / rpds

Python bindings to the Rust rpds crate for persistent data structures
https://rpds.readthedocs.io/
MIT License
41 stars 14 forks source link

Make Python 3.13 Compatible #79

Closed FlickerSoul closed 4 months ago

FlickerSoul commented 4 months ago

This is currently a draft PR. See https://github.com/crate-py/rpds/issues/72#issuecomment-2208113824.

edgarrmondragon commented 4 months ago

I was working on

but if we can make the jump to pyo3 0.22 in this PR, I think that's preferable :)

edgarrmondragon commented 4 months ago

You need to add 3.13 to https://github.com/crate-py/rpds/blob/2fce4247f95a43b32de3d0800bb26cb856a562f2/.github/workflows/CI.yml#L60-L66

FlickerSoul commented 4 months ago

@edgarrmondragon Thank you so much for the tips! I'll take a look at your PR tomorrow and can merge anything that can be added.

I'm not quite confident in my implementation. If you have time, it would be great to hear your ideas. Thanks!

edgarrmondragon commented 4 months ago

@edgarrmondragon Thank you so much for the tips! I'll take a look at your PR tomorrow and can merge anything that can be added.

I'm not quite confident in my implementation. If you have time, it would be great to hear your ideas. Thanks!

Changes look good to me, but I'm also not super familiar with pyo3' API (old or new) 😅. Maybe @davidhewitt can take a quick look in case something's majorly fumbled here.

FlickerSoul commented 4 months ago

@Julian Hi Julian, this PR should be ready for review. It bumps PyO3 to 0.22.1 and passes tests in Python 3.13 with GIL. However, it still breaks under the free-threaded Python. I'm happy to wait for updates from PyO3 and integrate so that rpds works on both variants of 3.13. What do you think?

davidhewitt commented 4 months ago

PyO3 will likely be a release or two before we support free-threaded Python properly, though it's very high priority on my TODO list.

I think probably we should be adjusting PyO3 to fail builds with a helpful error on free-threaded builds for the moment (maybe will release as 0.22.2). So I would advise not to wait for free-threaded support from us :)

FlickerSoul commented 4 months ago

@davidhewitt Thank you so much for your insight! I can submit a PR to allow PyO3 fail builds on free-threaded Python if that's helpful. :)

Julian commented 4 months ago

Thank you all for your help here, it's really appreciated! I'm going to merge I think. Thanks again!

davidhewitt commented 4 months ago

@davidhewitt Thank you so much for your insight! I can submit a PR to allow PyO3 fail builds on free-threaded Python if that's helpful. :)

@FlickerSoul a PR would be greatly appreciated. You'd need to modify pyo3-build-config to detect the freethreaded build and then emit an error similar to how we already check for supported Python versions.

EwoutH commented 4 months ago

6 minutes ago I added 3.13 to my CI setup and rpds was failing. Looked up the issues, saw 3 minutes ago rpds v0.19.0 was released, re-ran and it passed.

Awesome timing, and thanks a lot!