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

Change pyproject.toml to require the oldest possible numpy version to prevent future backwards-breaking numpy ABI changes #346

Closed
davidghiurco opened this issue Feb 10, 2022 · 1 comment · Fixed by #349

Comments

@davidghiurco
Copy link
Contributor

davidghiurco commented Feb 10, 2022

Describe the bug

Currently the 0.8.1.0 release pyproject.toml has:

[build-system]
requires = ["setuptools", "wheel", "numpy>=1.20", "cython>=0.23"]
build-backend = "setuptools.build_meta"

The problem with numpy>=1.20 is that for source installations, as well as wheel builds, this will actually use the latest (at build time) version of numpy. This can have the unintended consequence of making the resulting POT build compatible only with that latest numpy version (and newer).

This is because builds against numpy are forward compatible, but not backward compatible. (Source: numpy docs). What this means for POT is that it should be compiled against the oldest numpy version that it supports. In our current case, this would be numpy==1.20.0, not whatever is the newest version at the time of compilation with numpy>=1.20 in pyproject.toml.

Addressing this problem will prevent future bug reports when POT is inevitably built against numpy>=1.22, which has a backwards-breaking ABI change to 1.20.x & 1.21.x (see https://numpy.org/doc/stable/release/1.22.0-notes.html#compatibility-notes, and numpy/numpy#19479)

There is a meta-package developed by numpy devs called oldest-supported-numpy which is meant to be used exclusively in pyproject.toml for the purposes of building/compiling against numpy. Newer versions of numpy can still be used as runtime dependencies without breaking binary compatibility.

To Reproduce

Steps to reproduce the behavior:
1.build current codebase from latest release 0.8.1.0 from source, it will be built against numpy>=1.22.x (which was released December 31st, 2021).
2. Attempt to use the compiled package on a platform running numpy==1.20.x or numpy==1.21.x, you will get something similar to: ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 88 from C header, got 80 from PyObject

Expected behavior

POT should be built against the oldest numpy package it supports. This does not prevent using newer numpy versions as runtime dependencies.

Environment (please complete the following information):

  • OS (e.g. MacOS, Windows, Linux): MacOS Monterey, Version 12.1
  • Python version: 3.8+ (any python version that supports numpy 1.22.x is affected).
  • How was POT installed (source, pip, conda): pip & source, but this problem affects future wheel POT builds.
  • Build command you used (if compiling from source):
@davidghiurco davidghiurco changed the title Change pyproject.toml to require the oldest possible numpy version to prevent future backwards-breaking numpy ABI chan Change pyproject.toml to require the oldest possible numpy version to prevent future backwards-breaking numpy ABI changes Feb 10, 2022
@rflamary
Copy link
Collaborator

Hello @davidghiurco and thank you for the detailed explanation.

I'm OK with switching the pyproject.toml build dependency to oldest-supported-numpy instead of the current value since it will indeed provide since it will provide wheels that will work on most of the used version of numpy and it is the recommended strategy by numpy developers themselves.

Could you do a PR with this change and add build all wheels in the test of your commit to trigger wheels building and check that nothing breaks?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants