Support the free-threaded build of Python 3.14
- Avoids setting
py_limited_apion the free-threaded build. This tells CFFI to build version-specific wheels instead of abi3 wheels. - Updates the test jobs to add 3.14t tests.
- Updates the test jobs to only run tests for one python version by explicitly specifying a tox environment. Currently they run tests for several versions using interpreters that happen to be installed on the image.
- Adds a lock to the
CompressorandDecompressorclass and ensures that all operations that non-atomically read or mutate state on either class happen while the lock is held. Rather than introduce possible scaling bottlenecks, I've set up thethreading.Lockto always callacquire(blocking=False), and if the lock is already held by another thread, immediately raise an error. This enforces that it's not safe to shareCompressororDecompressorinstances while compression or decompression operations are happening. This follows the approach in https://github.com/google/brotli/pull/1386/. - Adds tests based on https://github.com/google/brotli/pull/1386/. The timing is slightly different than what's in that PR - ping @eustas - you may want to look at this.
- Updates wheel-building infrastructure to build cp314t wheels.
Open questions:
- Should I add a thread safety section to the documentation? Where?
- Should I add a pytest-run-parallel testing job to ensure there's no global state in the implementation of the pure functions in the API?
Argh: the test timing is flaky. There's probably a better way to synchronize things but I'm running out of steam. Suggestions to improve the tests are very welcome :)
It also occurred to me while working on this that the ubuntu wheel builds probably benefit from the new aarch64 CI runners on github actions. That would allow skipping the slow QEMU-emulated builds on ubuntu-latest.
ping @cclauss @zmedico - do you want to look this over?
Thank you @ngoldbaum, sorry I did not see the initial notification that this PR was opened. I can take a look, but please @cclauss and @zmedico take a look as well.