Repository navigation
ENH: Add NumPy declarations to be used by Cython 3.0+ - #17015
Merged
Merged
Conversation
* Create copy of numpy.pxd for Cython 3.0 changes and improve it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of #16986.
As discussed in cython/cython#3573, the latest alpha versions of Cython 3.0 need updated NumPy declarations to allow users to set
-D NPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION. Currently, builds with that setting fail with NumPy 1.19.[01] because thenumpy/__init__.pxdin NumPy overrides the more current one in Cython 3.0.This PR adds an updated copy of
numpy/__init__.pxdasnumpy/__init__.cython-30.pxdto make Cython 3.0+ use it.I first created a copy of the original
__init__.pxdin order to make the changes visible in the diff. Two additional changes:check_size ignoredeclarations in there. Cython has never had them (except for the one onndarray), and that's what people were probably using, but … not my decision, I guess.numpy.broadcastused to have struct fields defined in the NumPy version but not in the Cython version previously, so keeping them out is probably ok, but would now break backwards compatibility with NumPy 1.19.[01], where Cython 0.29.x already picks up the (old) NumPy version. Can't say how important that is for you. If at all, then they should rather be added as C-properties (as with thendarrayfields).Whatever you decide, I'll follow in the Cython-3.0-side version of the file.