@@ -384,7 +384,7 @@ def get_extensions(self):
384384 ])
385385 add_numpy_flags (ext )
386386 add_libagg_flags_and_sources (ext )
387- FreeType () .add_flags (ext )
387+ FreeType .add_flags (ext )
388388 yield ext
389389 # c_internal_utils
390390 ext = Extension (
@@ -412,7 +412,7 @@ def get_extensions(self):
412412 "src/mplutils.cpp" ,
413413 "src/py_converters.cpp" ,
414414 ])
415- FreeType () .add_flags (ext )
415+ FreeType .add_flags (ext )
416416 add_numpy_flags (ext )
417417 add_libagg_flags (ext )
418418 yield ext
@@ -441,7 +441,7 @@ def get_extensions(self):
441441 "matplotlib._qhull" , ["src/qhull_wrap.c" ],
442442 define_macros = [("MPL_DEVNULL" , os .devnull )])
443443 add_numpy_flags (ext )
444- add_qhull_flags (ext )
444+ Qhull . add_flags (ext )
445445 yield ext
446446 # tkagg
447447 ext = Extension (
@@ -550,17 +550,6 @@ def add_libagg_flags_and_sources(ext):
550550 os .path .join ("extern" , "agg24-svn" , "src" , x ) for x in agg_sources )
551551
552552
553- def add_qhull_flags (ext ):
554- if options .get ("system_qhull" ):
555- ext .libraries .append ("qhull" )
556- else :
557- qhull_path = Path (f'build/qhull-{ LOCAL_QHULL_VERSION } /src' )
558- ext .include_dirs .insert (0 , str (qhull_path ))
559- ext .sources .extend (map (str , sorted (qhull_path .glob ('libqhull_r/*.c' ))))
560- if sysconfig .get_config_var ("LIBM" ) == "-lm" :
561- ext .libraries .extend ("m" )
562-
563-
564553# First compile checkdep_freetype2.c, which aborts the compilation either
565554# with "foo.h: No such file or directory" if the header is not found, or an
566555# appropriate error message if the header indicates a too-old version.
@@ -569,7 +558,8 @@ def add_qhull_flags(ext):
569558class FreeType (SetupPackage ):
570559 name = "freetype"
571560
572- def add_flags (self , ext ):
561+ @classmethod
562+ def add_flags (cls , ext ):
573563 ext .sources .insert (0 , 'src/checkdep_freetype2.c' )
574564 if options .get ('system_freetype' ):
575565 pkg_config_setup_extension (
@@ -686,6 +676,36 @@ def do_custom_build(self, env):
686676 shutil .copy2 (lib_path , src_path / "objs/.libs/libfreetype.lib" )
687677
688678
679+ class Qhull (SetupPackage ):
680+ name = "qhull"
681+ _extensions_to_update = []
682+
683+ @classmethod
684+ def add_flags (cls , ext ):
685+ if options .get ("system_qhull" ):
686+ ext .libraries .append ("qhull_r" )
687+ else :
688+ cls ._extensions_to_update .append (ext )
689+
690+ def do_custom_build (self , env ):
691+ if options .get ('system_qhull' ):
692+ return
693+
694+ toplevel = get_and_extract_tarball (
695+ urls = ["http://www.qhull.org/download/qhull-2020-src-8.0.2.tgz" ],
696+ sha = "b5c2d7eb833278881b952c8a52d20179eab87766b00b865000469a45c1838b7e" ,
697+ dirname = f"qhull-{ LOCAL_QHULL_VERSION } " ,
698+ )
699+ shutil .copyfile (toplevel / "COPYING.txt" , "LICENSE/LICENSE_QHULL" )
700+
701+ for ext in self ._extensions_to_update :
702+ qhull_path = Path (f'build/qhull-{ LOCAL_QHULL_VERSION } /src' )
703+ ext .include_dirs .insert (0 , str (qhull_path ))
704+ ext .sources .extend (map (str , sorted (qhull_path .glob ('libqhull_r/*.c' ))))
705+ if sysconfig .get_config_var ("LIBM" ) == "-lm" :
706+ ext .libraries .extend ("m" )
707+
708+
689709class BackendMacOSX (OptionalPackage ):
690710 config_category = 'gui_support'
691711 name = 'macosx'
0 commit comments