diff --git a/INSTALL.rst b/INSTALL.rst index b14eb39e19cb..4d983d063f0d 100644 --- a/INSTALL.rst +++ b/INSTALL.rst @@ -109,7 +109,6 @@ Dependencies Matplotlib requires the following dependencies: * `Python `_ (>= 3.6) -* `FreeType `_ (>= 2.3) * `NumPy `_ (>= 1.11) * `setuptools `_ * `cycler `_ (>= 0.10.0) @@ -154,24 +153,27 @@ etc., you can install the following: * `LaTeX `_ and `GhostScript (>=9.0) `_ : for rendering text with LaTeX. -FreeType --------- +FreeType and Qhull +------------------ -Matplotlib depends on FreeType, a font rendering library. By default, -Matplotlib downloads and builds its own copy of FreeType. +Matplotlib depends on `FreeType `_ (>= 2.3), a +font rendering library, and on `Qhull `_ (>= 2015.2), +a library for computing triangulations. By default, Matplotlib downloads and +builds its own copy of FreeType, and uses its own copy of Qhull. -To force Matplotlib to use a copy of FreeType already installed in your system, -create a :file:`setup.cfg` file with the following contents: +To force Matplotlib to use a copy of FreeType or Qhull already installed in +your system, create a :file:`setup.cfg` file with the following contents: .. code-block:: cfg [libs] system_freetype = true + system_qhull = true before running ``python -m pip install .``. -In this case, you need to install the FreeType library and headers. This can -be achieved using a package manager: +In this case, you need to install the FreeType and Qhull library and headers. +This can be achieved using a package manager, e.g. for FreeType: .. code-block:: sh @@ -181,6 +183,8 @@ be achieved using a package manager: brew install freetype # macOS with Homebrew conda install freetype # conda, any OS +(adapt accordingly for Qhull). + On Linux and macOS, it is also recommended to install pkg-config_, a helper tool for locating FreeType: @@ -197,7 +201,7 @@ tool for locating FreeType: .. _pkg-config: https://www.freedesktop.org/wiki/Software/pkg-config/ If not using pkg-config (in particular on Windows), you may need to set the -include path (to the FreeType headers) and link path (to the FreeType library) +include path (to the library headers) and link path (to the libraries) explicitly, if they are not in standard locations. This can be done using standard environment variables -- on Linux and OSX: @@ -215,10 +219,9 @@ and on Windows: .. note:: - The following libraries are shipped with Matplotlib: + Matplotlib always uses its own copies of the following libraries: - ``Agg``: the Anti-Grain Geometry C++ rendering engine; - - ``qhull``: to compute Delaunay triangulation; - ``ttconv``: a TrueType font utility. Building on Windows diff --git a/setup.cfg.template b/setup.cfg.template index 05ca512c7d69..fd6cfeddcc6a 100644 --- a/setup.cfg.template +++ b/setup.cfg.template @@ -4,10 +4,11 @@ [egg_info] [libs] -# By default, Matplotlib downloads and builds its own copy of FreeType. You -# may set the following variable to True to instead link against a system -# FreeType. +# By default, Matplotlib downloads and builds its own copy of FreeType, and +# builds its own copy of Qhull. You may set the following to True to instead +# link against a system FreeType/Qhull. #system_freetype = False +#system_qhull = False [packages] # There are a number of data subpackages from Matplotlib that are diff --git a/setupext.py b/setupext.py index 26624a6578e1..7a39c7a0ed9a 100644 --- a/setupext.py +++ b/setupext.py @@ -149,20 +149,17 @@ def write_cache(local_fn, data): # matplotlib build options, which can be altered using setup.cfg -options = { - 'backend': None, -} - - setup_cfg = os.environ.get('MPLSETUPCFG', 'setup.cfg') +config = configparser.ConfigParser() if os.path.exists(setup_cfg): - config = configparser.ConfigParser() config.read(setup_cfg) - options['backend'] = config.get('rc_options', 'backend', fallback=None) - options['system_freetype'] = config.getboolean('libs', 'system_freetype', - fallback=False) -else: - config = None +options = { + 'backend': config.get('rc_options', 'backend', fallback=None), + 'system_freetype': config.getboolean('libs', 'system_freetype', + fallback=False), + 'system_qhull': config.getboolean('libs', 'system_qhull', + fallback=False), +} if '-q' in sys.argv or '--quiet' in sys.argv: @@ -318,8 +315,7 @@ def get_config(cls): insensitively defined as 0, false, no, off for False). """ conf = cls.default_config - if (config is not None - and config.has_option(cls.config_category, cls.name)): + if config.has_option(cls.config_category, cls.name): try: conf = config.getboolean(cls.config_category, cls.name) except ValueError: @@ -614,13 +610,13 @@ class Qhull(SetupPackage): name = "qhull" def add_flags(self, ext): - # Qhull doesn't distribute pkg-config info, so we have no way of - # knowing whether a system install is recent enough. Thus, always use - # the vendored version. - ext.include_dirs.insert(0, 'extern') - ext.sources.extend(sorted(glob.glob('extern/libqhull/*.c'))) - if sysconfig.get_config_var('LIBM') == '-lm': - ext.libraries.extend('m') + if options.get('system_qhull'): + ext.libraries.append('qhull') + else: + ext.include_dirs.insert(0, 'extern') + ext.sources.extend(sorted(glob.glob('extern/libqhull/*.c'))) + if sysconfig.get_config_var('LIBM') == '-lm': + ext.libraries.extend('m') class TTConv(SetupPackage):