@@ -98,8 +98,8 @@ toolchain is prefixed. This may be used for cross compiling. ::
98
98
export CXX=x86_64-pc-linux-gnu-g++
99
99
export PKG_CONFIG=x86_64-pc-linux-gnu-pkg-config
100
100
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.
103
103
::
104
104
105
105
cd matplotlib
@@ -165,96 +165,78 @@ etc., you can install the following:
165
165
* `LaTeX <https://miktex.org/ >`_ and `GhostScript (>=9.0)
166
166
<https://ghostscript.com/download/> `_ : for rendering text with LaTeX.
167
167
168
- .. note ::
169
-
170
- Matplotlib depends on non-Python libraries.
168
+ FreeType
169
+ --------
171
170
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 .
175
174
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:
177
178
178
- If not using pkg-config (in particular on Windows), you may need to set
179
- the include path (to the FreeType headers) and link path (to the FreeType
180
- library) explicitly, if they are not in standard locations. This can be
181
- done using standard environment variables -- on Linux and OSX:
179
+ .. code-block :: sh
182
180
183
- .. code-block :: sh
181
+ export MPLLOCALFREETYPE=1
184
182
185
- export CFLAGS=' -I/directory/containing/ft2build.h'
186
- export LDFLAGS=' -L/directory/containing/libfreetype.so'
183
+ and on Windows:
187
184
188
- and on Windows:
185
+ .. code-block :: bat
189
186
190
- .. code-block :: bat
187
+ set MPLLOCALFREETYPE = 1
191
188
192
- set CL = /IC:\directory\containing\ft2build.h
193
- set LINK = /LIBPATH:C:\directory\containing\freetype.lib
194
-
195
- .. note ::
189
+ and you can continue the installation (``python -mpip install . ``), ignoring
190
+ everything that follows.
196
191
197
- The following libraries are shipped with Matplotlib:
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:
198
194
199
- - ``Agg ``: the Anti-Grain Geometry C++ rendering engine;
200
- - ``qhull ``: to compute Delaunay triangulation;
201
- - ``ttconv ``: a TrueType font utility.
195
+ .. code-block :: sh
202
196
203
- .. _build_linux :
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
204
202
205
- Building on Linux
206
- -----------------
203
+ On Linux and macOS, it is also recommended to install pkg-config _, a helper
204
+ tool for locating FreeType:
207
205
208
- It is easiest to use your system package manager to install the dependencies.
206
+ .. code-block :: sh
209
207
210
- If you are on Debian/Ubuntu, you can get all the dependencies
211
- required to build Matplotlib with::
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
212
213
213
- sudo apt-get build-dep python-matplotlib
214
+ .. _ pkg-config : https://www.freedesktop.org/wiki/Software/pkg-config/
214
215
215
- If you are on Fedora, you can get all the dependencies required to build
216
- Matplotlib with::
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:
217
220
218
- sudo dnf builddep python-matplotlib
221
+ .. code-block :: sh
219
222
220
- If you are on RedHat, you can get all the dependencies required to build
221
- Matplotlib by first installing `` yum-builddep `` and then running::
223
+ export CFLAGS= ' -I/directory/containing/ft2build.h '
224
+ export LDFLAGS= ' -L/directory/containing/libfreetype.so '
222
225
223
- su -c "yum-builddep python-matplotlib"
226
+ and on Windows:
224
227
225
- These commands do not build Matplotlib, but instead get and install the
226
- build dependencies, which will make building from source easier.
228
+ .. code-block :: bat
227
229
228
- .. _build_osx :
230
+ set CL = /IC:\directory\containing\ft2build.h
231
+ set LINK = /LIBPATH:C:\directory\containing\freetype.lib
229
232
230
- Building on macOS
231
- -----------------
232
-
233
- The build situation on macOS is complicated by the various places one
234
- can get FreeType (MacPorts, Fink,
235
- /usr/X11R6), the different architectures (e.g., x86, ppc, universal), and
236
- the different macOS versions (e.g., 10.4 and 10.5). We recommend that you build
237
- the way we do for the macOS release: get the source from the tarball or the
238
- git repository and install the required dependencies through a third-party
239
- package manager. Two widely used package managers are Homebrew, and MacPorts.
240
- The following example illustrates how to install FreeType using
241
- ``brew ``::
242
-
243
- brew install freetype pkg-config
244
-
245
- If you are using MacPorts, execute the following instead::
246
-
247
- port install freetype pkgconfig
248
-
249
- After installing the above requirements, install Matplotlib from source by
250
- executing::
233
+ .. note ::
251
234
252
- python -mpip install .
235
+ The following libraries are shipped with Matplotlib:
253
236
254
- Note that your environment is somewhat important. Some conda users have
255
- found that, to run the tests, their PYTHONPATH must include
256
- /path/to/anaconda/.../site-packages and their DYLD_FALLBACK_LIBRARY_PATH
257
- 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.
258
240
259
241
.. _build_windows :
260
242
@@ -264,40 +246,14 @@ Building on Windows
264
246
The Python shipped from https://www.python.org is compiled with Visual Studio
265
247
2015 for 3.5+. Python extensions should be compiled with the same
266
248
compiler, see e.g.
267
- 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
268
250
for how to set up a build environment.
269
251
270
- Since there is no canonical Windows package manager, the methods for building
271
- FreeType from source code are documented as a build script
272
- at `matplotlib-winbuild <https://github.com/jbmohler/matplotlib-winbuild >`_.
273
-
274
- There are a few possibilities to build Matplotlib on Windows:
275
-
276
- * Wheels via `matplotlib-winbuild <https://github.com/jbmohler/matplotlib-winbuild >`_
277
- * Wheels by using conda packages (see below)
278
- * Conda packages (see below)
279
-
280
252
If you are building your own Matplotlib wheels (or sdists), note that any DLLs
281
253
that you copy into the source tree will be packaged too.
282
254
283
- Wheel builds using conda packages
284
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
285
-
286
- This is a wheel build, but we use conda packages to get all the requirements.
287
- FreeType is statically linked and therefore not needed during the wheel install.
288
-
289
- Set up the conda environment. Note, if you want a qt backend, add ``pyqt `` to
290
- the list of conda packages.
291
-
292
- ::
293
-
294
- conda create -n "matplotlib_build" python=3.7 numpy python-dateutil pyparsing tornado cycler tk freetype
295
- conda activate matplotlib_build
296
- python setup.py bdist_wheel
297
-
298
-
299
255
Conda packages
300
- ^^^^^^^^^^^^^^
256
+ --------------
301
257
302
258
The conda packaging scripts for Matplotlib are available at
303
259
https://github.com/conda-forge/matplotlib-feedstock.
0 commit comments