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

numpy>2.0 compatibility / don't require oldest-supported-numpy #262

Closed
dweindl opened this issue Sep 6, 2024 · 6 comments · Fixed by #263
Closed

numpy>2.0 compatibility / don't require oldest-supported-numpy #262

dweindl opened this issue Sep 6, 2024 · 6 comments · Fixed by #263

Comments

@dweindl
Copy link

dweindl commented Sep 6, 2024

Hi, cyipopt currently requires oldestsupported-numpy during package installation. This was great until numpy 2.0 was released. Meanwhile, this prevents using cyipopt with numpy>=2.0. More details are provided in the deprecation notice of oldest-supported-numpy.

To reproduce:

  1. Create and activate a new virtual environment python -m venv delete_me && source delete_me/bin/activate

  2. Install cyipopt pip install -vvv "cyipopt>=1.4.1" --no-cache

    ...
    Collecting numpy==1.26.2 (from oldest-supported-numpy)
    ...
    Successfully installed cyipopt-1.4.1 numpy-2.1.1

    I.e. in the isolated build environment, where the cyipopt C-extension is build, numpy==1.26.2 is used, but in the user's environment, numpy-2.1.1 will be used (incompatible with the extension built against numpy<2.0).

  3. Try to import python -c "import cyipopt"

    A module that was compiled using NumPy 1.x cannot be run in
    NumPy 2.1.1 as it may crash. To support both 1.x and 2.x
    versions of NumPy, modules must be compiled with NumPy 2.0.
    Some module may need to rebuild instead e.g. with 'pybind11>=2.12'.
    
    If you are a user of the module, the easiest solution will be to
    downgrade to 'numpy<2' or try to upgrade the affected module.
    We expect that some modules will need time to support NumPy 2.
    
    ....
    

This is most likely what caused #260.

In the simplest case, this could be fixed by just replacing oldest-supported-numpy by numpy in pyproject.toml.

It would be great to see a numpy>2.0-compatible cyipopt version on PyPI.

@moorepants
Copy link
Collaborator

That seems like a simple fix, thanks for reporting. After reading the references you pointed to, it seems the numpy required for building cyipopt should be numpy > 2.0, so I'll set that in the pyproject file.

@moorepants
Copy link
Collaborator

Actually, maybe it should just be numpy without versions, as people may want to build against NumPy 1 for some reason and having >=2 would prevent that.

@moorepants
Copy link
Collaborator

Or maybe the minimum build time version should be 1.25:

By default, NumPy will expose an API that is backwards compatible with the oldest NumPy version that supports the currently oldest compatible Python version. NumPy 1.25.0 supports Python 3.9 and higher and NumPy 1.19 is the first version to support Python 3.9. Thus, we guarantee that, when using defaults, NumPy 1.25 will expose a C-API compatible with NumPy 1.19. (the exact version is set within NumPy-internal header files).

from https://numpy.org/devdocs/dev/depending_on_numpy.html#adding-a-dependency-on-numpy

@moorepants
Copy link
Collaborator

This gives slightly different advice:

image

@moorepants
Copy link
Collaborator

There is a new PyPi sdist release that should address this issue. Let me know if it doesn't.

@dweindl
Copy link
Author

dweindl commented Sep 9, 2024

Thanks for the quick response. Works as expected.

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

Successfully merging a pull request may close this issue.

2 participants