From d6aeade12c44a0ebcb7e3f8379f39f4b62909963 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Wed, 2 Jan 2019 18:22:21 +0100 Subject: [PATCH] When linking against libpng/zlib on Windows, use upstream lib names. See changelog for details. --- .appveyor.yml | 4 ++-- build_alllocal.cmd | 4 ++-- doc/api/next_api_changes/2019-01-02-AL.rst | 19 +++++++++++++++++++ setupext.py | 8 +++++++- 4 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 doc/api/next_api_changes/2019-01-02-AL.rst diff --git a/.appveyor.yml b/.appveyor.yml index 998b3ce29556..5a293c5e9619 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -77,8 +77,8 @@ install: # Let the install prefer the static builds of the libs - set LIBRARY_LIB=%CONDA_PREFIX%\Library\lib - mkdir lib || cmd /c "exit /b 0" - - copy /y %LIBRARY_LIB%\zlibstatic.lib lib\z.lib - - copy /y %LIBRARY_LIB%\libpng_static.lib lib\png.lib + - copy /y %LIBRARY_LIB%\zlibstatic.lib lib\zlib.lib + - copy /y %LIBRARY_LIB%\libpng16_static.lib lib\libpng16.lib # These z.lib / png.lib are not static versions but files which end up as # dependencies to the dll file. This is fine for the conda build, but not here # and for the wheels diff --git a/build_alllocal.cmd b/build_alllocal.cmd index 535042e08a66..08845a80fa16 100644 --- a/build_alllocal.cmd +++ b/build_alllocal.cmd @@ -20,8 +20,8 @@ IF NOT DEFINED CONDA_PREFIX ( :: copy the libs which have "wrong" names set LIBRARY_LIB=%CONDA_PREFIX%\Library\lib mkdir lib || cmd /c "exit /b 0" -copy %LIBRARY_LIB%\zlibstatic.lib lib\z.lib -copy %LIBRARY_LIB%\libpng_static.lib lib\png.lib +copy %LIBRARY_LIB%\zlibstatic.lib lib\zlib.lib +copy %LIBRARY_LIB%\libpng16_static.lib lib\libpng16.lib :: build the target python setup.py %TARGET% diff --git a/doc/api/next_api_changes/2019-01-02-AL.rst b/doc/api/next_api_changes/2019-01-02-AL.rst new file mode 100644 index 000000000000..7af8293d16b9 --- /dev/null +++ b/doc/api/next_api_changes/2019-01-02-AL.rst @@ -0,0 +1,19 @@ +Changes to the Windows build +```````````````````````````` + +Previously, when building the :mod:`matplotlib._png` extension, the build +script would add "png" and "z" to the extensions ``.libraries`` attribute (if +pkg-config information is not available, which is in particular the case on +Windows). + +In particular, this implies that the Windows build would look up files named +``png.lib`` and ``z.lib``; but neither libpng upstream nor zlib upstream +provides these files by default. (On Linux, this would look up ``libpng.so`` +and ``libz.so``, which are indeed standard names.) + +Instead, on Windows, we now look up ``libpng16.lib`` and ``zlib.lib``, which +*are* the upstream names for the shared libraries (as of libpng 1.6.x). + +For a statically-linked build, the upstream names are ``libpng16_static.lib`` +and ``zlibstatic.lib``; one still needs to manually rename them if such a build +is desired. diff --git a/setupext.py b/setupext.py index fe57442ff562..ad28a0f8e0d5 100644 --- a/setupext.py +++ b/setupext.py @@ -645,7 +645,13 @@ def get_extension(self): ext, 'libpng', atleast_version='1.2', alt_exec=['libpng-config', '--ldflags'], - default_libraries=['png', 'z']) + default_libraries=( + ['png', 'z'] if os.name == 'posix' else + # libpng upstream names their lib libpng16.lib, not png.lib. + # zlib upstream names their lib zlib.lib, not z.lib. + ['libpng16', 'zlib'] if os.name == 'nt' else + [] + )) add_numpy_flags(ext) return ext