Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 23fc9c3

Browse files
committed
Document how to set build paths.
1 parent e6ca9ee commit 23fc9c3

File tree

3 files changed

+46
-6
lines changed

3 files changed

+46
-6
lines changed

INSTALL.rst

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,35 @@ etc., you can install the following:
174174

175175
.. note::
176176

177-
Matplotlib depends on non-Python libraries. `pkg-config
178-
<https://www.freedesktop.org/wiki/Software/pkg-config/>`_ can be used
179-
to find required non-Python libraries and thus make the install go more
180-
smoothly if the libraries and headers are not in the expected locations.
177+
Matplotlib depends on non-Python libraries.
178+
179+
On Linux and OSX, pkg-config_ can be used to find required non-Python
180+
libraries and thus make the install go more smoothly if the libraries and
181+
headers are not in the expected locations.
182+
183+
.. _pkg-config: https://www.freedesktop.org/wiki/Software/pkg-config/
184+
185+
If not using pkg-config (in particular on Windows), you may need to set the
186+
include path (to the FreeType, libpng, and zlib headers) and link path (to
187+
the FreeType, libpng, and zlib libraries) explicitly, if they are not in
188+
standard locations. This can be done using standard environment variables
189+
-- on Linux and OSX:
190+
191+
.. code-block:: sh
192+
193+
export CFLAGS='-I/directory/containing/ft2build.h ...'
194+
export LDFLAGS='-L/directory/containing/libfreetype.so ...'
195+
196+
and on Windows:
197+
198+
.. code-block:: bat
199+
200+
set CL=/IC:\directory\containing\ft2build.h ...
201+
set LINK=/LIBPATH:C:\directory\containing\freetype.lib ...
202+
203+
where ``...`` means "also give, in the same format, the directories
204+
containing ``png.h`` and ``zlib.h`` for the include path, and for
205+
``libpng.so``/``png.lib`` and ``libz.so``/``z.lib`` for the link path."
181206

182207
.. note::
183208

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Changes to search paths for FreeType and libpng
2+
```````````````````````````````````````````````
3+
4+
The ``MPLBASEDIRLIST`` environment variables and ``basedirlist`` entry in
5+
``setup.cfg`` have no effect anymore. Instead, if building in situations where
6+
FreeType or libpng are not in the compiler or linker's default path, set the
7+
standard environment variables ``CFLAGS``/``LDFLAGS`` on Linux or OSX, or
8+
``CL``/``LINK`` on Windows, to indicate the relevant paths.
9+
10+
See details in :file:`INSTALL.rst`.

setupext.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,13 @@ def setup_extension(
286286
if self.pkg_config and atleast_version:
287287
subprocess.check_call(
288288
[*cmd, f"--atleast-version={atleast_version}"])
289-
flags = shlex.split(subprocess.check_output(
290-
[*cmd, "--cflags", "--libs"], universal_newlines=True))
289+
flags = shlex.split(
290+
# Use sys.getfilesystemencoding() to allow round-tripping
291+
# when passed back to later subprocess calls, not
292+
# locale.getpreferredencoding() which
293+
# universal_newlines=True would do.
294+
os.fsdecode(
295+
subprocess.check_output([*cmd, "--cflags", "--libs"])))
291296
except (OSError, subprocess.CalledProcessError):
292297
pass
293298
else:

0 commit comments

Comments
 (0)