From 33967f1c8d33762fca266273af2b1c80ee5c4431 Mon Sep 17 00:00:00 2001 From: "[6~" Date: Sun, 19 Apr 2020 12:16:49 -0500 Subject: [PATCH 1/2] Stop using recently-broken 'libraries' key in setup.py --- setup.py | 37 ++++++++++++++----------------------- 1 file changed, 14 insertions(+), 23 deletions(-) diff --git a/setup.py b/setup.py index d52d7b8..3d55e57 100644 --- a/setup.py +++ b/setup.py @@ -78,33 +78,24 @@ def main(): install_requires=["six"], - libraries=[ - ( - "metis", - { - "sources": ( - glob.glob("src/metis/GKlib/*.c") - + glob.glob("src/metis/*.c") - + glob.glob("src/metis/libmetis/*.c") - ), - "include_dirs": [ - "src/metis/GKlib", - "src/metis/include", - "src/metis/libmetis" - ], - } - )], - ext_modules=[ Extension( "pymetis._internal", - ["src/wrapper/wrapper.cpp"], + ( + ["src/wrapper/wrapper.cpp"] + + glob.glob("src/metis/GKlib/*.c") + + glob.glob("src/metis/*.c") + + glob.glob("src/metis/libmetis/*.c") + ), define_macros=list(extra_defines.items()), - include_dirs=["src/metis/include"] - + [ - get_pybind_include(), - get_pybind_include(user=True) - ], + include_dirs=[ + "src/metis/include", + "src/metis/GKlib", + "src/metis/include", + "src/metis/libmetis", + get_pybind_include(), + get_pybind_include(user=True) + ], extra_compile_args=conf["CXXFLAGS"], ), ], -- GitLab From 23201e09189682b8cbff239af5f6778f9e34fb6f Mon Sep 17 00:00:00 2001 From: "[6~" Date: Sun, 19 Apr 2020 14:25:25 -0500 Subject: [PATCH 2/2] Monkeypatch distutils to pass -std= only when compiling C++ --- aksetup_helper.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/aksetup_helper.py b/aksetup_helper.py index f90d085..f63fd88 100644 --- a/aksetup_helper.py +++ b/aksetup_helper.py @@ -941,9 +941,11 @@ class PybindBuildExtCommand(NumpyBuildExtCommand): def build_extensions(self): ct = self.compiler.compiler_type opts = self.c_opts.get(ct, []) + cxx_opts = [] + if ct in ['unix', 'mingw32']: opts.append('-DVERSION_INFO="%s"' % self.distribution.get_version()) - opts.append(cpp_flag(self.compiler)) + cxx_opts.append(cpp_flag(self.compiler)) if has_flag(self.compiler, '-fvisibility=hidden'): opts.append('-fvisibility=hidden') elif ct == 'msvc': @@ -951,7 +953,22 @@ class PybindBuildExtCommand(NumpyBuildExtCommand): for ext in self.extensions: ext.extra_compile_args = ext.extra_compile_args + opts - NumpyBuildExtCommand.build_extensions(self) + prev__compile = self.compiler._compile + + # -std=... used on C files causes an error on Apple LLVM + # https://gitlab.tiker.net/inducer/pymetis/-/jobs/102421 + def _compile(obj, src, ext, cc_args, extra_postargs, pp_opts): + if ext == ".cpp": + cc_args = cc_args + cxx_opts + + return prev__compile(obj, src, ext, cc_args, extra_postargs, pp_opts) + + self.compiler._compile = _compile + + try: + NumpyBuildExtCommand.build_extensions(self) + finally: + self.compiler._compile = prev__compile # }}} -- GitLab