Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2f8cfec

Browse files
committed
Remove C++ flags when compiling C files in qhull extension
1 parentf8226d8 commit2f8cfec

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

‎setup.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,15 @@ def has_flag(self, flagname):
6666
returnTrue
6767

6868

69+
# Wrapper for distutils.ccompiler.CCompiler._compile to remove C++-specific
70+
# flags when compiling C files.
71+
defcompile_wrapper(compiler,obj,src,ext,cc_args,extra_postargs,pp_opts):
72+
ifsrc.lower().endswith(".c"):
73+
extra_postargs=list(filter(lambdax:x[1:4]!="std",
74+
extra_postargs))
75+
compiler._compile_old(obj,src,ext,cc_args,extra_postargs,pp_opts)
76+
77+
6978
classBuildExtraLibraries(setuptools.command.build_ext.build_ext):
7079
deffinalize_options(self):
7180
self.distribution.ext_modules[:]= [
@@ -184,9 +193,20 @@ def build_extension(self, ext):
184193
orig_build_temp=self.build_temp
185194
self.build_temp=os.path.join(self.build_temp,ext.name)
186195
try:
196+
ifext.name=="matplotlib._qhull":
197+
# For qhull extension some C++ flags must be removed before
198+
# compiling C files.
199+
fromdistutils.ccompilerimportCCompiler
200+
self.compiler._compile_old=self.compiler._compile
201+
self.compiler._compile=compile_wrapper.__get__(
202+
self.compiler,CCompiler)
187203
super().build_extension(ext)
188204
finally:
189205
self.build_temp=orig_build_temp
206+
ifext.name=="matplotlib._qhull"andhasattr(
207+
self.compiler,"_compile_old"):
208+
self.compiler._compile=self.compiler._compile_old
209+
delattr(self.compiler,"_compile_old")
190210

191211

192212
defupdate_matplotlibrc(path):

‎setupext.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ def get_extensions(self):
435435
# qhull
436436
ext=Pybind11Extension(
437437
"matplotlib._qhull", ["src/_qhull_wrapper.cpp"],
438-
# Do not setcxx_std as C compilers do not recognise it.
438+
cxx_std=11,
439439
define_macros=[("MPL_DEVNULL",os.devnull)])
440440
Qhull.add_flags(ext)
441441
yieldext

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp