Add Cython flag to signal free-threading compatibility
These are the necessary changes for imagecodecs to signify that it's compatible with the Python 3.13 free-threaded build. I've run some tests and everything seems to be running fine with it, apart from the issue described in #112.
Thanks. I'll reconsider this when ready to test free-threading. It's probably better to enable freethreading_compatible per module after individual review and testing. The criteria for freethreading_compatible must be stricter than passing existing tests without crash, no?
A thing to note is that the GIL is dynamically enabled for the whole process even if there's just one extension module that does not set the freethreading_compatible flag. That's why we've been pretty aggressive in enabling the freethreading_compatible flag, since that enables testing for bigger codebases that include many dependencies.
Also, I'm happy to spend more time on this and do any testing you'd like to see. Apart from running the tests, I did a manual skim through the code as well, but that's always going to miss some stuff.
Thanks again. This will be in the next release, which requires Cython 3.1. Imagecodecs and tifffile tests pass on my Windows system with Python 3.13t.
Testing with pytest-run-parallel has identified a few places, which need to be wrapped with cython.critical_section.