Skip to content
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

Support Cython 3 (and also Python 3.13). #951

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

J08nY
Copy link

@J08nY J08nY commented Jan 16, 2025

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

  • I confirm that I have the right to submit this contribution under the project's MIT license.
  • I ran the tests, and all new and existing tests passed.
  • My changes don't require a change to the documentation, or if they do, I've added all required information.

@ngoldbaum
Copy link

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.

@J08nY
Copy link
Author

J08nY commented Feb 2, 2025

Any progress on getting this in and cutting a new release? Python 3.13 is now 4 months old.

@h-vetinari
Copy link

h-vetinari commented Feb 6, 2025

I would be willing to test this in conda-forge (where we run the test suite anyway), but thinc depends on srsly, confection & wasabi, so those need to be solved first.

image

Xref conda-forge/srsly-feedstock#53

@J08nY
Copy link
Author

J08nY commented Feb 7, 2025

I would be willing to test this in conda-forge (where we run the test suite anyway), but thinc depends on srsly, confection & wasabi, so those need to be solved first.

It seems that all of srsly, confection & wasabi now install under Python 3.13. Atleast in my environment.

@J08nY
Copy link
Author

J08nY commented Feb 7, 2025

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 defined

which 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

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.

pipenv install failed with spacy 3.8.2 and thinc 8.3.2. Support for cython 3.x
3 participants