SINTEF / Splipy

Spline modelling made easy.
GNU General Public License v3.0
100 stars 18 forks source link

Adapt to NumPy 2.0.0 #176

Open UnaiSan opened 2 weeks ago

UnaiSan commented 2 weeks ago

NumPy 2.0.0 has been released and splipy is not working well with it yet.

Python 3.12.0 (tags/v3.12.0:0fb18b0, Oct  2 2023, 13:03:39) [MSC v.1935 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import splipy

A module that was compiled using NumPy 1.x cannot be run in
NumPy 2.0.0 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.

Traceback (most recent call last):  File "<stdin>", line 1, in <module>
  File "C:\Users\SanMiguelU\Documents\python\temp\.venv_np2\Lib\site-packages\splipy\__init__.py", line 1, in <module>
    from .basis import BSplineBasis
  File "C:\Users\SanMiguelU\Documents\python\temp\.venv_np2\Lib\site-packages\splipy\basis.py", line 10, in <module>
    from . import basis_eval, state
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\SanMiguelU\Documents\python\temp\.venv_np2\Lib\site-packages\splipy\__init__.py", line 1, in <module>
    from .basis import BSplineBasis
  File "C:\Users\SanMiguelU\Documents\python\temp\.venv_np2\Lib\site-packages\splipy\basis.py", line 10, in <module>
    from . import basis_eval, state
  File "splipy\\basis_eval.pyx", line 1, in init splipy.basis_eval
ImportError: numpy.core.multiarray failed to import (auto-generated because you didn't call 'numpy.import_array()' after cimporting numpy; use '<void>numpy._import_array' to disable if you are certain you don't need it).

I am going to specify numpy<2 in my code(s), but it would be nice if splipy was adapted.

TheBB commented 2 weeks ago

Thanks, I'll have a look at this and build a new version.

In fact I was a bit surprised you were even able to install Splipy together with Numpy 2 because our dependency is explicitly <2, but it seems the last Splipy release was made before that change, so it hasn't made its way to PyPI yet.