Commit 4095f032 authored by Stefan Behnel's avatar Stefan Behnel

Assume that code passed into cython.inline() is always NumPy 1.7+ clean, so...

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.
parent 5b2a3af1
...@@ -228,6 +228,7 @@ def cython_inline(code, get_type=unsafe_type, ...@@ -228,6 +228,7 @@ def cython_inline(code, get_type=unsafe_type,
os.makedirs(lib_dir) os.makedirs(lib_dir)
if force or not os.path.isfile(module_path): if force or not os.path.isfile(module_path):
cflags = [] cflags = []
define_macros = []
c_include_dirs = [] c_include_dirs = []
qualified = re.compile(r'([.\w]+)[.]') qualified = re.compile(r'([.\w]+)[.]')
for type, _ in arg_sigs: for type, _ in arg_sigs:
...@@ -238,6 +239,7 @@ def cython_inline(code, get_type=unsafe_type, ...@@ -238,6 +239,7 @@ def cython_inline(code, get_type=unsafe_type,
if m.groups()[0] == 'numpy': if m.groups()[0] == 'numpy':
import numpy import numpy
c_include_dirs.append(numpy.get_include()) c_include_dirs.append(numpy.get_include())
define_macros.append(("NPY_NO_DEPRECATED_API", "NPY_1_7_API_VERSION"))
# cflags.append('-Wno-unused') # cflags.append('-Wno-unused')
module_body, func_body = extract_func_code(code) module_body, func_body = extract_func_code(code)
params = ', '.join(['%s %s' % a for a in arg_sigs]) params = ', '.join(['%s %s' % a for a in arg_sigs])
...@@ -260,10 +262,12 @@ def __invoke(%(params)s): ...@@ -260,10 +262,12 @@ def __invoke(%(params)s):
finally: finally:
fh.close() fh.close()
extension = Extension( extension = Extension(
name = module_name, name=module_name,
sources = [pyx_file], sources=[pyx_file],
include_dirs = c_include_dirs, include_dirs=c_include_dirs or None,
extra_compile_args = cflags) extra_compile_args=cflags or None,
define_macros=define_macros or None,
)
if build_extension is None: if build_extension is None:
build_extension = _get_build_extension() build_extension = _get_build_extension()
build_extension.extensions = cythonize( build_extension.extensions = cythonize(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment