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

Skip to content

Commit 6a31fed

Browse files
committed
Don't link ft2font to zlib.
A default build of freetype (e.g. the one from MPLLOCALFREETYPE=1) uses its own vendored version of zlib (see FT_CONFIG_OPTION_SYSTEM_ZLIB in ftoption.h), so we don't need to link to zlib in that case; if we're linking against a system freetype then we can assume that pkg-config will list the right libraries to link. Not linking zlib explicitly means that the staticbuild option is not used anymore and can just be stripped out.
1 parent 8ea326c commit 6a31fed

File tree

4 files changed

+16
-58
lines changed

4 files changed

+16
-58
lines changed

.appveyor.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ install:
6060
# if conda-forge gets a new pyqt, it might be nice to install it as well to have more backends
6161
# https://github.com/conda-forge/conda-forge.github.io/issues/157#issuecomment-223536381
6262
- conda create -q -n test-environment python=%PYTHON_VERSION%
63-
freetype=2.6 zlib=1.2 tk=8.5
63+
freetype=2.6 tk=8.5
6464
pip setuptools numpy sphinx tornado
6565
- activate test-environment
6666
- echo %PYTHON_VERSION% %TARGET_ARCH%
@@ -81,9 +81,9 @@ test_script:
8181
# Now build the thing..
8282
- set LINK=/LIBPATH:%cd%\lib
8383
- pip install -ve .
84-
# these should show no z or freetype dll...
84+
# this should show no freetype dll...
8585
- set "DUMPBIN=%VS140COMNTOOLS%\..\..\VC\bin\dumpbin.exe"
86-
- 'if x%MPLSTATICBUILD% == xTrue "%DUMPBIN%" /DEPENDENTS lib\matplotlib\ft2font*.pyd | findstr freetype.*.dll && exit /b 1 || exit /b 0'
86+
- '"%DUMPBIN%" /DEPENDENTS lib\matplotlib\ft2font*.pyd | findstr freetype.*.dll && exit /b 1 || exit /b 0'
8787

8888
# this are optional dependencies so that we don't skip so many tests...
8989
- if x%TEST_ALL% == xyes conda install -q ffmpeg inkscape miktex pillow
@@ -98,9 +98,8 @@ test_script:
9898
- pytest %PYTEST_ARGS%
9999

100100
after_test:
101-
# After the tests were a success, build wheels with the static libs
101+
# After the tests were a success, build wheels.
102102
# Hide the output, the copied files really clutter the build log...
103-
- set MPLSTATICBUILD=True
104103
- 'python setup.py bdist_wheel > NUL:'
105104
- dir dist\
106105
- echo finished...

INSTALL.rst

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -175,27 +175,22 @@ etc., you can install the following:
175175

176176
.. _pkg-config: https://www.freedesktop.org/wiki/Software/pkg-config/
177177

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:
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:
183182

184183
.. code-block:: sh
185184
186-
export CFLAGS='-I/directory/containing/ft2build.h ...'
187-
export LDFLAGS='-L/directory/containing/libfreetype.so ...'
185+
export CFLAGS='-I/directory/containing/ft2build.h'
186+
export LDFLAGS='-L/directory/containing/libfreetype.so'
188187
189188
and on Windows:
190189

191190
.. code-block:: bat
192191
193-
set CL=/IC:\directory\containing\ft2build.h ...
194-
set LINK=/LIBPATH:C:\directory\containing\freetype.lib ...
195-
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."
192+
set CL=/IC:\directory\containing\ft2build.h
193+
set LINK=/LIBPATH:C:\directory\containing\freetype.lib
199194
200195
.. note::
201196

@@ -273,7 +268,7 @@ https://packaging.python.org/guides/packaging-binary-extensions/#setting-up-a-bu
273268
for how to set up a build environment.
274269

275270
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
271+
FreeType from source code are documented as a build script
277272
at `matplotlib-winbuild <https://github.com/jbmohler/matplotlib-winbuild>`_.
278273

279274
There are a few possibilities to build Matplotlib on Windows:
@@ -296,10 +291,8 @@ the list of conda packages.
296291

297292
::
298293

299-
conda create -n "matplotlib_build" python=3.7 numpy python-dateutil pyparsing tornado cycler tk zlib freetype
294+
conda create -n "matplotlib_build" python=3.7 numpy python-dateutil pyparsing tornado cycler tk freetype
300295
conda activate matplotlib_build
301-
# force the build against static zlib libraries
302-
set MPLSTATICBUILD=True
303296
python setup.py bdist_wheel
304297

305298

ci/azure-pipelines-steps.yml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,6 @@ steps:
1616
prerelease: true
1717
condition: and(succeeded(), eq(variables['python.version'], 'Pre'))
1818

19-
- ${{ if eq(parameters.installer, 'nuget') }}:
20-
- task: NuGetToolInstaller@0
21-
displayName: 'Use latest available Nuget'
22-
23-
- script: |
24-
nuget install zlib-msvc14-x64 -ExcludeVersion -OutputDirectory "$(build.BinariesDirectory)"
25-
echo ##vso[task.prependpath]$(build.BinariesDirectory)\zlib-msvc14-x64\build\native\bin_release
26-
27-
displayName: 'Install dependencies with nuget'
28-
2919
- ${{ if eq(parameters.installer, 'brew') }}:
3020
- script: |
3121
brew install pkg-config ffmpeg imagemagick mplayer ccache

setupext.py

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -151,32 +151,23 @@ def write_cache(local_fn, data):
151151
# matplotlib build options, which can be altered using setup.cfg
152152
options = {
153153
'backend': None,
154-
'staticbuild': False,
155-
}
154+
}
156155

157156

158157
setup_cfg = os.environ.get('MPLSETUPCFG', 'setup.cfg')
159158
if os.path.exists(setup_cfg):
160159
config = configparser.ConfigParser()
161160
config.read(setup_cfg)
162-
163161
if config.has_option('rc_options', 'backend'):
164162
options['backend'] = config.get("rc_options", "backend")
165-
166163
if config.has_option('test', 'local_freetype'):
167164
options['local_freetype'] = config.getboolean("test", "local_freetype")
168-
169-
if config.has_option('build', 'staticbuild'):
170-
options['staticbuild'] = config.getboolean("build", "staticbuild")
171165
else:
172166
config = None
173167

174168
lft = bool(os.environ.get('MPLLOCALFREETYPE', False))
175169
options['local_freetype'] = lft or options.get('local_freetype', False)
176170

177-
staticbuild = bool(os.environ.get('MPLSTATICBUILD', os.name == 'nt'))
178-
options['staticbuild'] = staticbuild or options.get('staticbuild', False)
179-
180171

181172
if '-q' in sys.argv or '--quiet' in sys.argv:
182173
def print_raw(*args, **kwargs): pass # Suppress our own output.
@@ -202,21 +193,6 @@ def get_buffer_hash(fd):
202193
return hasher.hexdigest()
203194

204195

205-
def deplib(libname):
206-
if sys.platform != 'win32':
207-
return libname
208-
209-
known_libs = {
210-
'z': ('zlib', 'static'),
211-
}
212-
213-
libname, static_postfix = known_libs[libname]
214-
if options['staticbuild']:
215-
libname += static_postfix
216-
217-
return libname
218-
219-
220196
@functools.lru_cache(1) # We only need to compute this once.
221197
def get_pkg_config():
222198
"""
@@ -521,7 +497,7 @@ def add_flags(self, ext):
521497
ext, 'freetype2',
522498
atleast_version='9.11.3',
523499
alt_exec=['freetype-config'],
524-
default_libraries=['freetype', deplib('z')])
500+
default_libraries=['freetype'])
525501
ext.define_macros.append(('FREETYPE_BUILD_TYPE', 'system'))
526502

527503
def do_custom_build(self):

0 commit comments

Comments
 (0)