@@ -98,8 +98,8 @@ toolchain is prefixed. This may be used for cross compiling. ::
9898 export CXX=x86_64-pc-linux-gnu-g++
9999 export PKG_CONFIG=x86_64-pc-linux-gnu-pkg-config
100100
101- Once you have satisfied the requirements detailed below (mainly
102- Python, NumPy, and FreeType), you can build Matplotlib.
101+ Once you have satisfied the requirements detailed below (i.e., Python and
102+ FreeType), you can build Matplotlib.
103103::
104104
105105 cd matplotlib
@@ -165,101 +165,78 @@ etc., you can install the following:
165165* `LaTeX <https://miktex.org/ >`_ and `GhostScript (>=9.0)
166166 <https://ghostscript.com/download/> `_ : for rendering text with LaTeX.
167167
168- .. note ::
169-
170- Matplotlib depends on non-Python libraries.
168+ FreeType
169+ --------
171170
172- On Linux and OSX, pkg-config _ can be used to find required non-Python
173- libraries and thus make the install go more smoothly if the libraries and
174- headers are not in the expected locations .
171+ Matplotlib depends on FreeType, a font rendering library. It can either
172+ download and build its own copy of the library, or use a copy of FreeType
173+ already installed in your system .
175174
176- .. _pkg-config : https://www.freedesktop.org/wiki/Software/pkg-config/
175+ The easiest option is to make Matplotlib download and build FreeType. This is
176+ done by setting the :envvar: `MPLLOCALFREETYPE ` environment variable to 1 -- on
177+ Linux and OSX:
177178
178- If not using pkg-config (in particular on Windows), you may need to set the
179- include path (to the FreeType and zlib headers) and link path (to
180- the FreeType and zlib libraries) explicitly, if they are not in
181- standard locations. This can be done using standard environment variables
182- -- on Linux and OSX:
179+ .. code-block :: sh
183180
184- .. code-block :: sh
181+ export MPLLOCALFREETYPE=1
185182
186- export CFLAGS=' -I/directory/containing/ft2build.h ...'
187- export LDFLAGS=' -L/directory/containing/libfreetype.so ...'
183+ and on Windows:
188184
189- and on Windows:
185+ .. code-block :: bat
190186
191- .. code-block :: bat
187+ set MPLLOCALFREETYPE = 1
192188
193- set CL = /IC:\directory\containing\ft2build.h ...
194- set LINK = /LIBPATH:C:\directory\containing\freetype.lib .. .
189+ and you can continue the installation (`` python -m pip install . ``), ignoring
190+ everything that follows .
195191
196- where ``... `` means "also give, in the same format, the directories
197- containing ``zlib.h `` for the include path, and for
198- ``libz.so ``/``z.lib `` for the link path."
199-
200- .. note ::
192+ If you wish, instead, to use the system FreeType, you need to install the
193+ FreeType library and headers. This can be achieved using a package manager:
201194
202- The following libraries are shipped with Matplotlib:
195+ .. code-block :: sh
203196
204- - ``Agg ``: the Anti-Grain Geometry C++ rendering engine;
205- - ``qhull ``: to compute Delaunay triangulation;
206- - ``ttconv ``: a TrueType font utility.
197+ # Pick ONE of the following:
198+ sudo apt install libfreetype6-dev # Debian/Ubuntu
199+ sudo dnf install freetype-devel # Fedora
200+ brew install freetype # macOS with Homebrew
201+ conda install freetype # conda, any OS
207202
208- .. _build_linux :
203+ On Linux and macOS, it is also recommended to install pkg-config _, a helper
204+ tool for locating FreeType:
209205
210- Building on Linux
211- -----------------
206+ .. code-block :: sh
212207
213- It is easiest to use your system package manager to install the dependencies.
208+ # Pick ONE of the following:
209+ sudo apt install pkg-config # Debian/Ubuntu
210+ sudo dnf install pkgconf # Fedora
211+ brew install pkg-config # macOS with Homebrew
212+ conda install pkg-config # conda
214213
215- If you are on Debian/Ubuntu, you can get all the dependencies
216- required to build Matplotlib with::
214+ .. _pkg-config : https://www.freedesktop.org/wiki/Software/pkg-config/
217215
218- sudo apt-get build-dep python-matplotlib
216+ If not using pkg-config (in particular on Windows), you may need to set the
217+ include path (to the FreeType headers) and link path (to the FreeType library)
218+ explicitly, if they are not in standard locations. This can be done using
219+ standard environment variables -- on Linux and OSX:
219220
220- If you are on Fedora, you can get all the dependencies required to build
221- Matplotlib with::
221+ .. code-block :: sh
222222
223- sudo dnf builddep python-matplotlib
223+ export CFLAGS=' -I/directory/containing/ft2build.h'
224+ export LDFLAGS=' -L/directory/containing/libfreetype.so'
224225
225- If you are on RedHat, you can get all the dependencies required to build
226- Matplotlib by first installing ``yum-builddep `` and then running::
226+ and on Windows:
227227
228- su -c "yum-builddep python-matplotlib"
228+ .. code-block :: bat
229229
230- These commands do not build Matplotlib, but instead get and install the
231- build dependencies, which will make building from source easier.
230+ set CL = /IC:\directory\containing\ft2build.h
231+ set LINK = /LIBPATH:C:\directory\containing\freetype.lib
232232
233- .. _build_osx :
234-
235- Building on macOS
236- -----------------
237-
238- The build situation on macOS is complicated by the various places one
239- can get FreeType (MacPorts, Fink,
240- /usr/X11R6), the different architectures (e.g., x86, ppc, universal), and
241- the different macOS versions (e.g., 10.4 and 10.5). We recommend that you build
242- the way we do for the macOS release: get the source from the tarball or the
243- git repository and install the required dependencies through a third-party
244- package manager. Two widely used package managers are Homebrew, and MacPorts.
245- The following example illustrates how to install FreeType using
246- ``brew ``::
247-
248- brew install freetype pkg-config
249-
250- If you are using MacPorts, execute the following instead::
251-
252- port install freetype pkgconfig
253-
254- After installing the above requirements, install Matplotlib from source by
255- executing::
233+ .. note ::
256234
257- python -m pip install .
235+ The following libraries are shipped with Matplotlib:
258236
259- Note that your environment is somewhat important. Some conda users have
260- found that, to run the tests, their PYTHONPATH must include
261- /path/to/anaconda/.../site-packages and their DYLD_FALLBACK_LIBRARY_PATH
262- must include /path/to/anaconda/lib.
237+ - ``Agg ``: the Anti-Grain Geometry C++ rendering engine;
238+ - ``qhull ``: to compute Delaunay triangulation;
239+ - ``ttconv ``: a TrueType font utility.
263240
264241.. _build_windows :
265242
@@ -269,42 +246,14 @@ Building on Windows
269246The Python shipped from https://www.python.org is compiled with Visual Studio
2702472015 for 3.5+. Python extensions should be compiled with the same
271248compiler, see e.g.
272- https://packaging.python.org/guides/packaging-binary-extensions/#setting-up-a-build-environment-on -windows
249+ https://packaging.python.org/guides/packaging-binary-extensions/#binary-extensions-for -windows
273250for how to set up a build environment.
274251
275- Since there is no canonical Windows package manager, the methods for building
276- FreeType and zlib from source code are documented as a build script
277- at `matplotlib-winbuild <https://github.com/jbmohler/matplotlib-winbuild >`_.
278-
279- There are a few possibilities to build Matplotlib on Windows:
280-
281- * Wheels via `matplotlib-winbuild <https://github.com/jbmohler/matplotlib-winbuild >`_
282- * Wheels by using conda packages (see below)
283- * Conda packages (see below)
284-
285252If you are building your own Matplotlib wheels (or sdists), note that any DLLs
286253that you copy into the source tree will be packaged too.
287254
288- Wheel builds using conda packages
289- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
290-
291- This is a wheel build, but we use conda packages to get all the requirements.
292- FreeType is statically linked and therefore not needed during the wheel install.
293-
294- Set up the conda environment. Note, if you want a qt backend, add ``pyqt `` to
295- the list of conda packages.
296-
297- ::
298-
299- conda create -n "matplotlib_build" python=3.7 numpy python-dateutil pyparsing tornado cycler tk zlib freetype
300- conda activate matplotlib_build
301- # force the build against static zlib libraries
302- set MPLSTATICBUILD=True
303- python setup.py bdist_wheel
304-
305-
306255Conda packages
307- ^^^^^^^^^^^^^^
256+ --------------
308257
309258The conda packaging scripts for Matplotlib are available at
310259https://github.com/conda-forge/matplotlib-feedstock.
0 commit comments