From 133dfece64566b8c54217ebd665572eda6c96d70 Mon Sep 17 00:00:00 2001 From: Thomas VINCENT Date: Thu, 10 Jan 2019 17:52:22 +0100 Subject: [PATCH] Fix compile args issue with numpy 1.16.0rc2 Use different ways to provide compile args to numpy.distutils --- setup.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/setup.py b/setup.py index 53170e076..59d41661f 100644 --- a/setup.py +++ b/setup.py @@ -623,7 +623,8 @@ def patch_extension(self, ext): from Cython.Build import cythonize patched_exts = cythonize( [ext], - compiler_directives={'embedsignature': True}, + compiler_directives={'embedsignature': True, + 'language_level': 3}, force=self.force_cython, compile_time_env={"HAVE_OPENMP": self.use_openmp} ) @@ -649,8 +650,17 @@ def patch_extension(self, ext): extern = 'extern "C" ' if ext.language == 'c++' else '' return_type = 'void' if sys.version_info[0] <= 2 else 'PyObject*' - ext.extra_compile_args.append( - '''-fvisibility=hidden -D'PyMODINIT_FUNC=%s__attribute__((visibility("default"))) %s ' ''' % (extern, return_type)) + ext.extra_compile_args.append('-fvisibility=hidden') + + import numpy + numpy_version = [int(i) for i in numpy.version.short_version.split(".", 2)[:2]] + if numpy_version < [1,16]: + ext.extra_compile_args.append( + '''-D'PyMODINIT_FUNC=%s__attribute__((visibility("default"))) %s ' ''' % (extern, return_type)) + else: + ext.define_macros.append( + ('PyMODINIT_FUNC', + '%s__attribute__((visibility("default"))) %s ' % (extern, return_type))) def is_debug_interpreter(self): """ @@ -806,7 +816,8 @@ def cythonize_extensions(self): from Cython.Build import cythonize cythonize( self.extensions, - compiler_directives={'embedsignature': True}, + compiler_directives={'embedsignature': True, + 'language_level': 3}, force=True ) @@ -946,7 +957,7 @@ def get_project_configuration(dry_run): "numexpr", # for the use of pkg_resources on script launcher "setuptools", - "silx>=0.8"] + "silx>=0.9"] setup_requires = [ "setuptools",