diff --git a/pyproject.toml b/pyproject.toml index a7c4049..1a98f35 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,6 +4,6 @@ requires = ["setuptools>=42.0.0", "setuptools_scm", "wheel", "extension-helpers", - "numpy>=1.25"] + "numpy>=1.25,<2"] build-backend = 'setuptools.build_meta' diff --git a/setup.py b/setup.py index d7d110e..1d64191 100755 --- a/setup.py +++ b/setup.py @@ -34,6 +34,9 @@ def get_extensions(): 'define_macros': [ ('GSL_RANGE_CHECK_OFF', None), ('HAVE_INLINE', None), + ('Py_LIMITED_API', 0x03090000), + ('NPY_TARGET_VERSION', 'NPY_1_19_API_VERSION'), + ('NPY_NO_DEPRECATED_API', 'NPY_1_19_API_VERSION'), ], 'extra_compile_args': [ '-std=gnu11', diff --git a/src/core.c b/src/core.c index 752688e..74a7899 100644 --- a/src/core.c +++ b/src/core.c @@ -15,25 +15,6 @@ * along with this program. If not, see . */ -#define NPY_NO_DEPRECATED_API NPY_1_19_API_VERSION -#define Py_LIMITED_API 0x03090000 - -/* FIXME: - * The Numpy C-API defines PyArrayDescr_Type as: - * - * #define PyArrayDescr_Type (*(PyTypeObject *)PyArray_API[3]) - * - * and then in some places we need to take its address, &PyArrayDescr_Type. - * This is fine in GCC 10 and Clang, but earlier versions of GCC complain: - * - * error: dereferencing pointer to incomplete type 'PyTypeObject' - * {aka 'struct _typeobject'} - * - * As a workaround, provide a faux forward declaration for PyTypeObject. - * See https://github.com/numpy/numpy/issues/16970. - */ -struct _typeobject {}; - #ifdef _OPENMP #include #endif @@ -56,6 +37,24 @@ WARNINGS_POP #include "cubic_interp.h" #include "omp_interruptible.h" +/* FIXME: + * The Numpy C-API defines PyArrayDescr_Type as: + * + * #define PyArrayDescr_Type (*(PyTypeObject *)PyArray_API[3]) + * + * and then in some places we need to take its address, &PyArrayDescr_Type. + * This is fine in GCC 10 and Clang, but earlier versions of GCC complain: + * + * error: dereferencing pointer to incomplete type 'PyTypeObject' + * {aka 'struct _typeobject'} + * + * As a workaround, provide a faux forward declaration for PyTypeObject. + * See https://github.com/numpy/numpy/issues/16970. + */ +#ifndef PYPY_VERSION +struct _typeobject {}; +#endif + static PyObject * get_num_threads(PyObject *NPY_UNUSED(module), void *NPY_UNUSED(args))