SheffieldML / GPy

Gaussian processes framework in python
BSD 3-Clause "New" or "Revised" License
2.01k stars 558 forks source link

GPy will not install against Numpy 2.0 #1076

Closed edbennett closed 1 month ago

edbennett commented 2 months ago

Trying to build against Numpy 2.0 (released yesterday) gives the error:

0.606 aarch64-linux-gnu-gcc -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -Werror=implicit-function-declaration -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -mbranch-protection=standard -fPIC -I/venv/lib/python3.11/site-packages/numpy/_core/include -I. -I/venv/include -I/usr/include/python3.11 -c GPy/kern/src/stationary_cython.c -o build/temp.linux-aarch64-cpython-311/GPy/kern/src/stationary_cython.o -fopenmp -O3
0.668 In file included from /venv/lib/python3.11/site-packages/numpy/_core/include/numpy/ndarraytypes.h:1909,
0.668                  from /venv/lib/python3.11/site-packages/numpy/_core/include/numpy/ndarrayobject.h:12,
0.668                  from /venv/lib/python3.11/site-packages/numpy/_core/include/numpy/arrayobject.h:5,
0.668                  from GPy/kern/src/stationary_cython.c:750:
0.668 /venv/lib/python3.11/site-packages/numpy/_core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning "Using deprecated NumPy API, disable it with " "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
0.668    17 | #warning "Using deprecated NumPy API, disable it with " \
0.668       |  ^~~~~~~
0.679 In file included from /usr/include/python3.11/Python.h:38,
0.679                  from GPy/kern/src/stationary_cython.c:6:
0.679 GPy/kern/src/stationary_cython.c: In function ‘__pyx_f_5numpy_PyDataType_SHAPE’:
0.682 GPy/kern/src/stationary_cython.c:4159:39: error: ‘PyArray_Descr’ {aka ‘struct _PyArray_Descr’} has no member named ‘subarray’
0.682  4159 |     __Pyx_INCREF(((PyObject*)__pyx_v_d->subarray->shape));
0.682       |                                       ^~
0.682 /usr/include/python3.11/pyport.h:24:38: note: in definition of macro ‘_Py_CAST’
0.682    24 | #define _Py_CAST(type, expr) ((type)(expr))
0.682       |                                      ^~~~
0.682 /usr/include/python3.11/object.h:506:35: note: in expansion of macro ‘_PyObject_CAST’
0.682   506 | #  define Py_INCREF(op) Py_INCREF(_PyObject_CAST(op))
0.682       |                                   ^~~~~~~~~~~~~~
0.682 GPy/kern/src/stationary_cython.c:1536:27: note: in expansion of macro ‘Py_INCREF’
0.682  1536 |   #define __Pyx_INCREF(r) Py_INCREF(r)
0.682       |                           ^~~~~~~~~
0.682 GPy/kern/src/stationary_cython.c:4159:5: note: in expansion of macro ‘__Pyx_INCREF’
0.682  4159 |     __Pyx_INCREF(((PyObject*)__pyx_v_d->subarray->shape));
0.682       |     ^~~~~~~~~~~~
0.682 GPy/kern/src/stationary_cython.c:4160:36: error: ‘PyArray_Descr’ {aka ‘struct _PyArray_Descr’} has no member named ‘subarray’
0.682  4160 |     __pyx_r = ((PyObject*)__pyx_v_d->subarray->shape);
0.682       |                                    ^~
1.052 error: command '/usr/bin/aarch64-linux-gnu-gcc' failed with exit code 1

I'm surprised that the "deprecated" API seems to have changed but not entirely disappeared. I imagine that for the time being, a quick fix would be to require numpy < 2.0.

MartinBubel commented 2 months ago

Hi @edbennett thanks for reporting this one.

Sure, limiting numpy to < 2 would be an easy fix. Feel free to make a PR if you can find the time. I can also do it but it may take a while.

Best, Martin