Skip to content

Commit a62201a

Browse files
committed
Fix building aganst system Qhull.
1 parent 77b1374 commit a62201a

File tree

2 files changed

+33
-24
lines changed

2 files changed

+33
-24
lines changed

setup.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@
4747
from distutils.dist import Distribution
4848

4949
import setupext
50-
from setupext import (
51-
get_and_extract_tarball, print_raw, print_status, LOCAL_QHULL_VERSION)
50+
from setupext import print_raw, print_status
5251

5352
# Get the version from versioneer
5453
import versioneer
@@ -61,6 +60,7 @@
6160
setupext.Python(),
6261
setupext.Platform(),
6362
setupext.FreeType(),
63+
setupext.Qhull(),
6464
setupext.SampleData(),
6565
setupext.Tests(),
6666
setupext.BackendMacOSX(),
@@ -86,18 +86,8 @@ def __init__(self, dist):
8686
"'python setup.py test'. Please run 'pytest'.")
8787

8888

89-
def _download_qhull():
90-
toplevel = get_and_extract_tarball(
91-
urls=["http://www.qhull.org/download/qhull-2020-src-8.0.2.tgz"],
92-
sha="b5c2d7eb833278881b952c8a52d20179eab87766b00b865000469a45c1838b7e",
93-
dirname=f"qhull-{LOCAL_QHULL_VERSION}",
94-
)
95-
shutil.copyfile(toplevel / "COPYING.txt", "LICENSE/LICENSE_QHULL")
96-
97-
9889
class BuildExtraLibraries(BuildExtCommand):
9990
def finalize_options(self):
100-
_download_qhull()
10191
self.distribution.ext_modules[:] = [
10292
ext
10393
for package in good_packages

setupext.py

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
690709
class BackendMacOSX(OptionalPackage):
691710
config_category = 'gui_support'
692711
name = 'macosx'

0 commit comments

Comments
 (0)