Skip to content

Commit

Permalink
Fix compile args issue with numpy 1.16.0rc2
Browse files Browse the repository at this point in the history
Use different ways to provide compile args to numpy.distutils
  • Loading branch information
t20100 authored and kif committed Apr 24, 2019
1 parent 3e80bdf commit 133dfec
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}
)
Expand All @@ -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):
"""
Expand Down Expand Up @@ -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
)

Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 133dfec

Please sign in to comment.