Build failures against NumPy 2.0 with GCC 14
mgorny opened this issue · 8 comments
When using a stricter compiler (e.g. GCC 14) and building against NumPy 2.0.0rc2, the build fails over a bunch of type mismatches:
building 'fitsio._fitsio_wrap' extension
creating build/temp.linux-x86_64-cpython-312/fitsio
gcc-14 -fno-strict-overflow -Wsign-compare -fPIC -I/usr/lib/python3.12/site-packages/numpy/_core/include -Ibuild/temp.linux-x86_64-cpython-312/cfitsio-4.2.0 -Ibuild/temp.linux-x86_64-cpython-312/cfitsio-4.2.0 -I/usr/include/python3.12 -c fitsio/fitsio_pywrap.c -o build/temp.linux-x86_64-cpython-312/fitsio/fitsio_pywrap.o
In file included from /usr/lib/python3.12/site-packages/numpy/_core/include/numpy/ndarraytypes.h:1909,
from /usr/lib/python3.12/site-packages/numpy/_core/include/numpy/ndarrayobject.h:12,
from /usr/lib/python3.12/site-packages/numpy/_core/include/numpy/arrayobject.h:5,
from fitsio/fitsio_pywrap.c:28:
/usr/lib/python3.12/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]
17 | #warning "Using deprecated NumPy API, disable it with " \
| ^~~~~~~
fitsio/fitsio_pywrap.c: In function ‘get_int64_from_array’:
fitsio/fitsio_pywrap.c:561:29: error: passing argument 1 of ‘PyArray_TYPE’ from incompatible pointer type [-Wincompatible-pointer-types]
561 | npy_type = PyArray_TYPE(arr);
| ^~~
| |
| PyObject * {aka struct _object *}
/usr/lib/python3.12/site-packages/numpy/_core/include/numpy/ndarraytypes.h:1563:35: note: expected ‘const PyArrayObject *’ {aka ‘const struct tagPyArrayObject_fields *’} but argument is of type ‘PyObject *’ {aka ‘struct _object *’}
1563 | PyArray_TYPE(const PyArrayObject *arr)
| ~~~~~~~~~~~~~~~~~~~~~^~~
/usr/lib/python3.12/site-packages/numpy/_core/include/numpy/ndarraytypes.h:1021:50: error: passing argument 1 of ‘PyArray_CHKFLAGS’ from incompatible pointer type [-Wincompatible-pointer-types]
1021 | #define PyArray_ISCONTIGUOUS(m) PyArray_CHKFLAGS((m), NPY_ARRAY_C_CONTIGUOUS)
| ^~~
| |
| PyObject * {aka struct _object *}
fitsio/fitsio_pywrap.c:575:10: note: in expansion of macro ‘PyArray_ISCONTIGUOUS’
575 | if (!PyArray_ISCONTIGUOUS(arr)) {
| ^~~~~~~~~~~~~~~~~~~~
/usr/lib/python3.12/site-packages/numpy/_core/include/numpy/ndarraytypes.h:1569:39: note: expected ‘const PyArrayObject *’ {aka ‘const struct tagPyArrayObject_fields *’} but argument is of type ‘PyObject *’ {aka ‘struct _object *’}
1569 | PyArray_CHKFLAGS(const PyArrayObject *arr, int flags)
| ~~~~~~~~~~~~~~~~~~~~~^~~
fitsio/fitsio_pywrap.c:580:28: error: passing argument 1 of ‘PyArray_DATA’ from incompatible pointer type [-Wincompatible-pointer-types]
580 | colnums = PyArray_DATA(arr);
| ^~~
| |
| PyObject * {aka struct _object *}
/usr/lib/python3.12/site-packages/numpy/_core/include/numpy/ndarraytypes.h:1508:35: note: expected ‘const PyArrayObject *’ {aka ‘const struct tagPyArrayObject_fields *’} but argument is of type ‘PyObject *’ {aka ‘struct _object *’}
1508 | PyArray_DATA(const PyArrayObject *arr)
| ~~~~~~~~~~~~~~~~~~~~~^~~
fitsio/fitsio_pywrap.c:581:27: error: passing argument 1 of ‘PyArray_DIMS’ from incompatible pointer type [-Wincompatible-pointer-types]
581 | *ncols = PyArray_SIZE(arr);
| ^~~
| |
| PyObject * {aka struct _object *}
/usr/lib/python3.12/site-packages/numpy/_core/include/numpy/ndarrayobject.h:79:59: note: in definition of macro ‘PyArray_SIZE’
79 | #define PyArray_SIZE(m) PyArray_MultiplyList(PyArray_DIMS(m), PyArray_NDIM(m))
| ^
/usr/lib/python3.12/site-packages/numpy/_core/include/numpy/ndarraytypes.h:1520:35: note: expected ‘const PyArrayObject *’ {aka ‘const struct tagPyArrayObject_fields *’} but argument is of type ‘PyObject *’ {aka ‘struct _object *’}
1520 | PyArray_DIMS(const PyArrayObject *arr)
| ~~~~~~~~~~~~~~~~~~~~~^~~
fitsio/fitsio_pywrap.c:581:27: error: passing argument 1 of ‘PyArray_NDIM’ from incompatible pointer type [-Wincompatible-pointer-types]
581 | *ncols = PyArray_SIZE(arr);
| ^~~
| |
| PyObject * {aka struct _object *}
/usr/lib/python3.12/site-packages/numpy/_core/include/numpy/ndarrayobject.h:79:76: note: in definition of macro ‘PyArray_SIZE’
79 | #define PyArray_SIZE(m) PyArray_MultiplyList(PyArray_DIMS(m), PyArray_NDIM(m))
| ^
/usr/lib/python3.12/site-packages/numpy/_core/include/numpy/ndarraytypes.h:1502:35: note: expected ‘const PyArrayObject *’ {aka ‘const struct tagPyArrayObject_fields *’} but argument is of type ‘PyObject *’ {aka ‘struct _object *’}
1502 | PyArray_NDIM(const PyArrayObject *arr)
| ~~~~~~~~~~~~~~~~~~~~~^~~
fitsio/fitsio_pywrap.c: In function ‘PyFITSObject_create_image_hdu’:
fitsio/fitsio_pywrap.c:1451:34: error: passing argument 1 of ‘PyArray_TYPE’ from incompatible pointer type [-Wincompatible-pointer-types]
1451 | npy_dtype = PyArray_TYPE(array);
| ^~~~~
| |
| PyObject * {aka struct _object *}
[…]
(the list is actually quite long)
Hi All 👋
NumPy is planning to release 2.0 on June 16th ( numpy/numpy#24300 (comment) ). NumPy 2.0.0 RC packages for conda & wheels came out at the beginning of April ( numpy/numpy#24300 (comment) )
NumPy has put out a migration guide. More details are in the release notes
If fitsio makes use of NumPy's C API (and produces wheels that use it), having a release of fitsio with wheels built against NumPy 2.0.0rc1 would be helpful to ensure NumPy 1 & 2 compatible wheels (as wheels built against NumPy 1 won't be compatible with NumPy 2). More details in this NumPy 2 ABI doc
Also as NumPy is tracking ecosystem support for NumPy 2.0, it would be helpful to share fitsio current support status in issue (with any plans): numpy/numpy#26191
Thanks. We definitely have some work to do but it looks mostly mechanical.
Yes, it does. Thanks a lot!
Thanks all! 🙏
Should we close this issue then? Or do you want to wait for a release?
I'm thinking to close and make a release ASAP, but I'm happy to hear counterarguments.
SGTM
Feel free to close it.