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

Backwards incompatible change in C API with Numpy 1.20 #8

Closed
jpgill86 opened this issue Mar 30, 2021 · 1 comment
Closed

Backwards incompatible change in C API with Numpy 1.20 #8

jpgill86 opened this issue Mar 30, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@jpgill86
Copy link
Member

jpgill86 commented Mar 30, 2021

As is explained here, Numpy 1.20 introduced a change to its C API. This affects Python packages with compiled components that depend on Numpy, such as axographio. The version of Numpy installed at compile time can limit the versions of Numpy compatible with the package at run time. That is:

  • The API changes are not backwards-compatible: If axographio is built with Numpy 1.20, the wheel will not be compatible with installations running older versions of Numpy.
  • Numpy 1.20 is still compatible with older wheels: If axographio is built with Numpy 1.19, the wheel will still be compatible with installations running newer versions of Numpy.

Unaware of any of this, today I published a new wheel for Python 3.9 to PyPI (axographio-0.3.1-cp39-cp39-win_amd64.whl). I had Numpy 1.20 installed when building. The wheel is incompatible with Python 3.9 installations running Numpy 1.19, resulting in this error when trying to read a file:

ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 88 from C header, got 80 from PyObject

Because setup.py does not indicate a run-time requirement of Numpy 1.20, anyone installing axographio into an environment with Python 3.9 and Numpy 1.19 or older will get a broken version of axographio.

I don't have the privileges on PyPI needed to replace or delete the bad wheel. To work around this, I plan to release a new version of axographio built with Numpy 1.19, which should be compatible with Numpy 1.20 too. The only change will be a version number bump.

@jpgill86 jpgill86 added the bug Something isn't working label Mar 30, 2021
jpgill86 added a commit that referenced this issue Mar 30, 2021
Numpy 1.20 introduced a backwards-incompatible change to its C API, such that wheels built with Numpy 1.20 are incompatible with installations running Numpy 1.19 or older. To avoid problems like issue #8 in the future, axographio will now require Numpy 1.20 or later.
@jpgill86
Copy link
Member Author

jpgill86 commented Mar 30, 2021

The plan seems to have worked. Release 0.3.2, built with Numpy 1.19, works with both Numpy 1.19 and 1.20. I will close this issue now, but this could become a problem again in the future unless the project shifts to requiring Numpy 1.20 or later. I have opened PR #9, which can be included in the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant