@@ -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.
@@ -687,6 +676,36 @@ def do_custom_build(self, env):
687676 shutil .copy2 (lib_path , src_path / "objs/.libs/libfreetype.lib" )
688677
689678
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+
690709class BackendMacOSX (OptionalPackage ):
691710 config_category = 'gui_support'
692711 name = 'macosx'
0 commit comments