Skip to content

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

@davidghiurco

Description

@davidghiurco

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):

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions