From 4095f032ef78dbe9ccefd6a19802da56e05d99f4 Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Sat, 11 Apr 2020 13:02:30 +0200 Subject: Assume that code passed into cython.inline() is always NumPy 1.7+ clean, so that we can get rid of the C compiler warning about deprecated NumPy API usage. --- Cython/Build/Inline.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Cython/Build/Inline.py b/Cython/Build/Inline.py index eaff9bd1a..813ba5cd1 100644 --- a/Cython/Build/Inline.py +++ b/Cython/Build/Inline.py @@ -228,6 +228,7 @@ def cython_inline(code, get_type=unsafe_type, os.makedirs(lib_dir) if force or not os.path.isfile(module_path): cflags = [] + define_macros = [] c_include_dirs = [] qualified = re.compile(r'([.\w]+)[.]') for type, _ in arg_sigs: @@ -238,6 +239,7 @@ def cython_inline(code, get_type=unsafe_type, if m.groups()[0] == 'numpy': import numpy c_include_dirs.append(numpy.get_include()) + define_macros.append(("NPY_NO_DEPRECATED_API", "NPY_1_7_API_VERSION")) # cflags.append('-Wno-unused') module_body, func_body = extract_func_code(code) params = ', '.join(['%s %s' % a for a in arg_sigs]) @@ -260,10 +262,12 @@ def __invoke(%(params)s): finally: fh.close() extension = Extension( - name = module_name, - sources = [pyx_file], - include_dirs = c_include_dirs, - extra_compile_args = cflags) + name=module_name, + sources=[pyx_file], + include_dirs=c_include_dirs or None, + extra_compile_args=cflags or None, + define_macros=define_macros or None, + ) if build_extension is None: build_extension = _get_build_extension() build_extension.extensions = cythonize( -- cgit v1.2.1