8000 Merge pull request #15476 from anntzer/default-to-local-freetype · matplotlib/matplotlib@5d6f889 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5d6f889

Browse files
authored
Merge pull request #15476 from anntzer/default-to-local-freetype
BLD: Default to local_freetype builds.
2 parents f7fa86a + c092ecd commit 5d6f889

13 files changed

+49
-105
lines changed

.appveyor.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,6 @@ install:
7272
curl -sL https://github.com/python/cpython/pull/1224.patch |
7373
patch -fsup 1 -d %CONDA_PREFIX% ) || cmd /c "exit /b 0"
7474

75-
# enables the local freetype build
76-
- set MPLLOCALFREETYPE=1
7775
# Show the installed packages + versions
7876
- conda list
7977

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ install:
156156
export CPPFLAGS=--coverage
157157
fi
158158
- |
159-
MPLLOCALFREETYPE=1 python -mpip install -ve . # Install Matplotlib.
159+
python -mpip install -ve . # Install Matplotlib.
160160
- |
161161
if [[ $TRAVIS_OS_NAME != 'osx' ]] && [[ $RUN_PYTEST == 1 ]]; then
162162
unset CPPFLAGS

INSTALL.rst

Lines changed: 13 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -90,19 +90,8 @@ the latest *tar.gz* release file from `the PyPI files page
9090
develop Matplotlib or just need the latest bugfixed version, grab the
9191
latest git version, and see :ref:`install-from-git`.
9292

93-
The standard environment variables :envvar:`CC`, :envvar:`CXX`,
94-
:envvar:`PKG_CONFIG` are respected. This means you can set them if your
95-
toolchain is prefixed. This may be used for cross compiling. ::
93+
Matplotlib can be installed from the source directory with a simple ::
9694

97-
export CC=x86_64-pc-linux-gnu-gcc
98-
export CXX=x86_64-pc-linux-gnu-g++
99-
export PKG_CONFIG=x86_64-pc-linux-gnu-pkg-config
100-
101-
Once you have satisfied the requirements detailed below (i.e., Python and
102-
FreeType), you can build Matplotlib.
103-
::
104-
105-
cd matplotlib
10695
python -m pip install .
10796

10897
We provide a setup.cfg_ file which you can use to customize the build
@@ -168,29 +157,21 @@ etc., you can install the following:
168157
FreeType
169158
--------
170159

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.
174-
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:
178-
179-
.. code-block:: sh
180-
181-
export MPLLOCALFREETYPE=1
160+
Matplotlib depends on FreeType, a font rendering library. By default,
161+
Matplotlib downloads and builds its own copy of FreeType.
182162

183-
and on Windows:
163+
To force Matplotlib to use a copy of FreeType already installed in your system,
164+
create a :file:`setup.cfg` file with the following contents:
184165

185-
.. code-block:: bat
166+
.. code-block:: cfg
186167
187-
set MPLLOCALFREETYPE=1
168+
[libs]
169+
system_freetype = true
188170
189-
and you can continue the installation (``python -m pip install .``), ignoring
190-
everything that follows.
171+
before running ``python -m pip install .``.
191172

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:
173+
In this case, you need to install the FreeType library and headers. This can
174+
be achieved using a package manager:
194175

195176
.. code-block:: sh
196177
@@ -210,6 +191,8 @@ tool for locating FreeType:
210191
sudo dnf install pkgconf # Fedora
211192
brew install pkg-config # macOS with Homebrew
212193
conda install pkg-config # conda
194+
# Or point the PKG_CONFIG environment variable to the path to pkg-config:
195+
export PKG_CONFIG=...
213196
214197
.. _pkg-config: https://www.freedesktop.org/wiki/Software/pkg-config/
215198

ci/azure-pipelines-steps.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ steps:
5454
displayName: 'Install dependencies with pip'
5555

5656
- bash: |
57-
MPLLOCALFREETYPE=1 python -m pip install -ve . ||
57+
python -m pip install -ve . ||
5858
[[ "$PYTHON_VERSION" = 'Pre' ]]
5959
displayName: "Install self"
6060

doc/devel/contributing.rst

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -92,30 +92,11 @@ and might be easier to use if you are using 2-factor authentication.
9292
Building Matplotlib for image comparison tests
9393
----------------------------------------------
9494

95-
Matplotlib's test suite makes heavy use of image comparison tests,
96-
meaning the result of a plot is compared against a known good result.
97-
Unfortunately, different versions of FreeType produce differently
98-
formed characters, causing these image comparisons to fail. To make
99-
them reproducible, Matplotlib can be built with a special local copy
100-
of FreeType. This is recommended for all Matplotlib developers.
101-
102-
Prior to compiling the C-extensions, copy :file:`setup.cfg.template` to
103-
:file:`setup.cfg` and edit it to contain::
104-
105-
[test]
106-
local_freetype = True
107-
tests = True
108-
109-
or set the ``MPLLOCALFREETYPE`` environmental variable to any true
110-
value. If you have previously built Matplotlib with a different
111-
version of Freetype, you will also need to remove the c/c++ build
112-
products. Do this is to delete the ``build`` folder or ``git clean
113-
-xfd``. If you are going to be regularly working on Matplotlib,
114-
consider putting ::
115-
116-
export MPLLOCALFREETYPE=1
117-
118-
in your shell start up files.
95+
Matplotlib's test suite makes heavy use of image comparison tests, meaning
96+
the result of a plot is compared against a known good result. Unfortunately,
97+
different versions of FreeType produce differently formed characters, causing
98+
these image comparisons to fail. To make them reproducible, Matplotlib is, by
99+
default, built with a special local copy of FreeType.
119100

120101

121102
Installing Matplotlib in developer mode

doc/devel/testing.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ Requirements
2121
------------
2222

2323
Install the latest version of Matplotlib as documented in
24-
:ref:`installing_for_devs` In particular, follow the instructions to use a
25-
local FreeType build.
24+
:ref:`installing_for_devs`.
2625

2726
The following software is required to run the tests:
2827

doc/faq/environment_variables_faq.rst

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,6 @@ Environment Variables
3434
is used to find a base directory in which the :file:`matplotlib` subdirectory
3535
is created.
3636

37-
.. envvar:: MPLLOCALFREETYPE
38-
39-
If set, this environment variable directs Matplotlib's build script to
40-
download and build its own copy of the FreeType library.
41-
4237
.. envvar:: PATH
4338

4439
The list of directories searched to find executable programs.

doc/faq/installing_faq.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,6 @@ or::
182182
and build and install with::
183183

184184
cd matplotlib
185-
export MPLLOCALFREETYPE=1 # on Linux and OSX.
186-
set MPLLOCALFREETYPE=1 # on Windows.
187185
python -mpip install .
188186

189187
If you want to be able to follow the development branch as it changes

lib/matplotlib/__init__.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1316,14 +1316,12 @@ def _init_tests():
13161316
if (ft2font.__freetype_version__ != LOCAL_FREETYPE_VERSION or
13171317
ft2font.__freetype_build_type__ != 'local'):
13181318
_log.warning(
1319-
"Matplotlib is not built with the correct FreeType version to run "
1320-
"tests. Set local_freetype=True in setup.cfg and rebuild. "
1321-
"Expect many image comparison failures below. "
1322-
"Expected freetype version {0}. "
1323-
"Found freetype version {1}. "
1324-
"Freetype build type is {2}local".format(
1325-
LOCAL_FREETYPE_VERSION,
1326-
ft2font.__freetype_version__,
1319+
f"Matplotlib is not built with the correct FreeType version to "
1320+
f"run tests. Rebuild without setting system_freetype=1 in "
1321+
f"setup.cfg. Expect many image comparison failures below. "
1322+
f"Expected freetype version {LOCAL_FREETYPE_VERSION}. "
1323+
f"Found freetype version {ft2font.__freetype_version__}. "
1324+
"Freetype build type is {}local".format(
13271325
"" if ft2font.__freetype_build_type__ == 'local' else "not "))
13281326

13291327
try:

setup.cfg.template

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@
33

44
[egg_info]
55

6-
[test]
7-
# If you plan to develop Matplotlib and run or add to the test suite,
8-
# set this to True. It will download and build a specific version of
9-
# FreeType, and then use that to build the ft2font extension. This
10-
# ensures that test images are exactly reproducible.
11-
#local_freetype = False
6+
[libs]
7+
# By default, Matplotlib downloads and builds its own copy of FreeType. You
8+
# may set the following variable to True to instead link against a system
9+
# FreeType.
10+
#system_freetype = False
1211

1312
[packages]
1413
# There are a number of data subpackages from Matplotlib that are

0 commit comments

Comments
 (0)
0