Using deprecated Numpy API Using deprecated Numpy API numpy numpy

Using deprecated Numpy API


This is a known issue, and it stems from the fact that Cython historically has supported very old numpy versions. As cython's doc mentions:

Despite this, you will still get warnings like the following from the compiler, because Cython is using a deprecated Numpy API:

.../include/numpy/npy_1_7_deprecated_api.h:15:2: warning: #warning"Using deprecated NumPy API, disable it by " "#definingNPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]

For the time being, it is just a warning that you can ignore.

However, there's work in progress in several pull requests and the parent issue tracking the progress can be found here.

Soon these warnings will be gone.


Until this is resolved upstream as mentioned by adrin, I found a way to insert the preprocessor symbol NPY_NO_DEPRECATED_API into the setup.py code so that the warning will be suppressed. Add the keyword define_macros=[args] to your Extension. Just putting it in your .h, .cpp, or .pyx files will not help because the auto-generated project .cpp file will not see the preprocessor defines.https://docs.python.org/2.0/dist/node13.html

Specifically for OP's case:

module1 = Extension('my_wrapper', sources = ['my_c_file.c'],      include_dirs=[numpy.get_include()],    extra_compile_args = ['-fopenmp'],    extra_link_args = ['-lgomp']),    define_macros=[('NPY_NO_DEPRECATED_API', 'NPY_1_7_API_VERSION')])

This will add -DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION to the compile line.

Fair warning: doing this may enable several new warnings that were suppressed because it was maintaining compatibility with old versions.