-
Notifications
You must be signed in to change notification settings - Fork 286
Support Cython 3 (and also Python 3.13). #951
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
It would also be neat to check the Cython 3.1 alpha release or Cython's master branch against free-threaded 3.13. See https://py-free-threading.github.io for more info about supporting free-threaded Python in native code. |
|
Any progress on getting this in and cutting a new release? Python 3.13 is now 4 months old. |
|
I would be willing to test this in conda-forge (where we run the test suite anyway), but |
It seems that all of |
|
I am getting lots of warnings while running tests under 3.13: thinc/tests/layers/test_layers_api.py: 1594 warnings
thinc/tests/layers/test_lstm.py: 238 warnings
thinc/tests/layers/test_transforms.py: 296 warnings
thinc/tests/layers/test_with_transforms.py: 2508 warnings
thinc/tests/model/test_validation.py: 145 warnings
thinc/tests/test_config.py: 66 warnings
/tmp/virt/lib/python3.13/site-packages/pydantic/v1/typing.py:68: DeprecationWarning: Failing to pass a value to the 'type_params' parameter of 'typing.ForwardRef._evaluate' is deprecated, as it leads to incorrect behaviour when calling typing.ForwardRef._evaluate on a stringified annotation that references a PEP 695 type parameter. It will be disallowed in Python 3.15.
return cast(Any, type_)._evaluate(globalns, localns, recursive_guard=set())Also some errors: ============================================================================================= short test summary info =============================================================================================
FAILED thinc/tests/backends/test_ops.py::test_ops_consistency[NumpyOps] - AssertionError: alloc
FAILED thinc/tests/layers/test_layers_api.py::test_layers_from_config[SparseLinear.v1-kwargs55-in_data55-out_data55] - NameError: name 'InT' is not defined
FAILED thinc/tests/layers/test_layers_api.py::test_layers_from_config[SparseLinear.v2-kwargs56-in_data56-out_data56] - NameError: name 'InT' is not defined
FAILED thinc/tests/layers/test_layers_api.py::test_layers_from_config[premap_ids.v1-kwargs59-in_data59-out_data59] - NameError: name 'InT' is not defined
FAILED thinc/tests/layers/test_layers_api.py::test_dropout[data2] - thinc.util.DataValidationError:
FAILED thinc/tests/layers/test_layers_api.py::test_layers_batching_all[premap_ids.v1-kwargs59-in_data59-out_data59] - NameError: name 'InT' is not definedwhich expand out to this, and are clearly connected to the warning: thinc/tests/layers/test_layers_api.py:211: in util_batch_unbatch_array
model.initialize(in_data, out_data)
thinc/model.py:316: in initialize
validate_fwd_input_output(self.name, self._func, X, Y)
thinc/util.py:588: in validate_fwd_input_output
ArgModel.update_forward_refs(**types.__dict__)
../virt/lib/python3.13/site-packages/pydantic/v1/main.py:814: in update_forward_refs
update_model_forward_refs(cls, cls.__fields__.values(), cls.__config__.json_encoders, localns)
../virt/lib/python3.13/site-packages/pydantic/v1/typing.py:559: in update_model_forward_refs
update_field_forward_refs(f, globalns=globalns, localns=localns)
../virt/lib/python3.13/site-packages/pydantic/v1/typing.py:525: in update_field_forward_refs
field.type_ = evaluate_forwardref(field.type_, globalns, localns or None)
../virt/lib/python3.13/site-packages/pydantic/v1/typing.py:68: in evaluate_forwardref
return cast(Any, type_)._evaluate(globalns, localns, recursive_guard=set())
/usr/lib/python3.13/typing.py:1081: in _evaluate
eval(self.__forward_code__, globalns, localns),Seems to be an upstream pydantic issue: pydantic/pydantic#9613 |
|
Pinging this. Could anyone have a look, fix the failing test and merge? It is blocking a lot of people depending on spacy. |
|
requirements.txt should also be updated, since it's referenced in the README. If no-one responds in a few more weeks, maybe email Explosion. |
|
I tried this in conda-forge/thinc-feedstock#126. On python <3.13, the test suite fails with: For 3.13, we'd also need to lift the cap here Line 37 in 256e403
because we only have 3.13 builds for blis>=1.1 (though it's technically possible to backport this to 1.0, that makes no sense IMO in terms of policy). |
|
I can confirm that this PR allows to build But for tests also need this change diff --git i/thinc/tests/layers/test_linear.py w/thinc/tests/layers/test_linear.py
index 345669d8..d91061a4 100644
--- i/thinc/tests/layers/test_linear.py
+++ w/thinc/tests/layers/test_linear.py
@@ -1,7 +1,7 @@
import numpy
import pytest
from hypothesis import given, settings
-from mock import MagicMock
+from unittest.mock import MagicMock
from numpy.testing import assert_allclose
from thinc.api import SGD, Dropout, Linear, chain
diff --git i/thinc/tests/layers/test_with_debug.py w/thinc/tests/layers/test_with_debug.py
index 3f65a3ac..3e31c71f 100644
--- i/thinc/tests/layers/test_with_debug.py
+++ w/thinc/tests/layers/test_with_debug.py
@@ -1,4 +1,4 @@
-from mock import MagicMock
+from unittest.mock import MagicMock
from thinc.api import Linear, with_debug
|
Does this fix all of the test failures? I haven't had a chance to try. |
|
It only fixes so that tests itself run. There are some test failures but I'm not sure if they're due Python 3.13 as they might be because of some other reason. |
|
Thanks for attention on this. We've had a size restriction on PyPi that prevented releases on spaCy, and there's issues associated with Python 3.13 to do with the Pydantic usage for validation. I'm working on the update now. We need to target the 8.3.x branch. That's the one spaCy uses. I've been streaming some spaCy and ecosystem development to increase transparency, so you can see some of the issues around Pydantic in this stream: https://www.youtube.com/watch?v=TTEWWJ2PmZQ&list=PLBmcuObd5An5_iAxNYLJa_xWmNzsYce8c&index=1&t=2882s . I've had to work on a consulting project the last couple of weeks so I had to pause work on this, but I'm back on it now. |
|
Guys any news on this? Lots of packages are depending on spaCy and it can't update to support for Py 3.13. |
|
Not sure how the just-released spacy 3.8.7 works with python 3.13, given that it has a |
|
PLEASE merge this PR so downstream dependencies like SpaCy (and my own projects) can finally use Python 3.13. |
|
This PR is not really ready though. I verified that the test failures still happen and I do not have time to fix investigate them. |
|
thinc v8.3.6 has been out for ~3 month with cython 3 & py313 support; the requirements file (on that branch) is not up to date though: Line 20 in 037c264
|
|
Interesting. Anyone knows, why this support is not in the master branch or the v9.x versions? |
|
@J08nY The v9 branch is ahead of what spaCy is supporting, and the plan is actually to phase out Thinc in spaCy, so I haven't been keeping it updated. Basically the v8.3.x branch is the one that matters. |
|
I see. So v8.3.x supports Python 3.13 and v9.x does not. And spaCy targets v8.3.x. So it may make sense to pick out the Python 3.13 support from the v8.3.x branch to main as well right? If that is possible. I will close this PR the, as it really does not do much and people should just use v8.3.x then. |

Note
v8.3.x supports Python 3.13, use that. If you are installing spaCy it targets
thinc <8.4.0anyway.Description
Fixes the build on Python 3.13 (with Cython 3). Fixes #926 and fixes #947.
Types of change
Removal of Cython version restriction and a small fix.
Checklist