Skip to content

ENH: Add NumPy declarations to be used by Cython 3.0+ - #17015

Merged
charris merged 1 commit into
numpy:maintenance/1.19.xfrom
charris:backport-16986
Aug 5, 2020
Merged

charris merged 1 commit into
numpy:maintenance/1.19.xfrom
charris:backport-16986

Conversation

@charris

@charris charris commented Aug 5, 2020

Copy link
Copy Markdown
Member

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 the numpy/__init__.pxd in NumPy overrides the more current one in Cython 3.0.

This PR adds an updated copy of numpy/__init__.pxd as numpy/__init__.cython-30.pxd to make Cython 3.0+ use it.

I first created a copy of the original __init__.pxd in order to make the changes visible in the diff. Two additional changes:

  • I'm not sure if we want the check_size ignore declarations in there. Cython has never had them (except for the one on ndarray), and that's what people were probably using, but … not my decision, I guess.
  • numpy.broadcast used 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 the ndarray fields).

Whatever you decide, I'll follow in the Cython-3.0-side version of the file.

* Create copy of numpy.pxd for Cython 3.0 changes and improve it.
@charris charris added this to the 1.19.2 release milestone Aug 5, 2020
@charris
charris merged commit 408d810 into numpy:maintenance/1.19.x Aug 5, 2020
@charris
charris deleted the backport-16986 branch August 5, 2020 22:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants