Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c733e40

Browse filesBrowse files
Kojoleytacaswell
authored andcommitted
BLD: Switch to static linking by default on windows
1 parent 7fa442a commit c733e40
Copy full SHA for c733e40

File tree

Expand file treeCollapse file tree

5 files changed

+35
-48
lines changed
Filter options
Expand file treeCollapse file tree

5 files changed

+35
-48
lines changed

‎.appveyor.yml

Copy file name to clipboardExpand all lines: .appveyor.yml
+4-13Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,6 @@ install:
7575
curl -sL https://github.com/python/cpython/pull/1224.patch |
7676
patch -fsup 1 -d %CONDA_PREFIX% ) || cmd /c "exit /b 0"
7777

78-
# Let the install prefer the static builds of the libs
79-
- set LIBRARY_LIB=%CONDA_PREFIX%\Library\lib
80-
- mkdir lib || cmd /c "exit /b 0"
81-
- copy /y %LIBRARY_LIB%\zlibstatic.lib lib\zlib.lib
82-
- copy /y %LIBRARY_LIB%\libpng16_static.lib lib\libpng16.lib
83-
# These z.lib / png.lib are not static versions but files which end up as
84-
# dependencies to the dll file. This is fine for the conda build, but not here
85-
# and for the wheels
86-
- del %LIBRARY_LIB%\png.lib
87-
- del %LIBRARY_LIB%\z.lib
8878
# enables the local freetype build
8979
- set MPLLOCALFREETYPE=1
9080
# Show the installed packages + versions
@@ -96,9 +86,9 @@ test_script:
9686
- pip install -ve .
9787
# these should show no z, png, or freetype dll...
9888
- set "DUMPBIN=%VS140COMNTOOLS%\..\..\VC\bin\dumpbin.exe"
99-
- '"%DUMPBIN%" /DEPENDENTS lib\matplotlib\ft2font*.pyd | findstr freetype.*.dll && exit /b 1 || exit /b 0'
100-
- '"%DUMPBIN%" /DEPENDENTS lib\matplotlib\_png*.pyd | findstr z.*.dll && exit /b 1 || exit /b 0'
101-
- '"%DUMPBIN%" /DEPENDENTS lib\matplotlib\_png*.pyd | findstr png.*.dll && exit /b 1 || exit /b 0'
89+
- 'if x%MPLSTATICBUILD% == xTrue "%DUMPBIN%" /DEPENDENTS lib\matplotlib\ft2font*.pyd | findstr freetype.*.dll && exit /b 1 || exit /b 0'
90+
- 'if x%MPLSTATICBUILD% == xTrue "%DUMPBIN%" /DEPENDENTS lib\matplotlib\_png*.pyd | findstr z.*.dll && exit /b 1 || exit /b 0'
91+
- 'if x%MPLSTATICBUILD% == xTrue "%DUMPBIN%" /DEPENDENTS lib\matplotlib\_png*.pyd | findstr png.*.dll && exit /b 1 || exit /b 0'
10292

10393
# this are optional dependencies so that we don't skip so many tests...
10494
- if x%TEST_ALL% == xyes conda install -q ffmpeg inkscape miktex pillow
@@ -115,6 +105,7 @@ test_script:
115105
after_test:
116106
# After the tests were a success, build wheels with the static libs
117107
# Hide the output, the copied files really clutter the build log...
108+
- set MPLSTATICBUILD=True
118109
- 'python setup.py bdist_wheel > NUL:'
119110
- dir dist\
120111
- echo finished...

‎INSTALL.rst

Copy file name to clipboardExpand all lines: INSTALL.rst
+3-4Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -307,11 +307,10 @@ the list of conda packages.
307307

308308
conda create -n "matplotlib_build" python=3.7 numpy python-dateutil pyparsing tornado cycler tk libpng zlib freetype msinttypes
309309
conda activate matplotlib_build
310+
# force the build against static libpng and zlib libraries
311+
set MPLSTATICBUILD=True
312+
python setup.py bdist_wheel
310313

311-
For building, call the script ``build_alllocal.cmd`` in the root folder of the
312-
repository::
313-
314-
build_alllocal.cmd
315314

316315
Conda packages
317316
^^^^^^^^^^^^^^

‎build_alllocal.cmd

Copy file name to clipboardExpand all lines: build_alllocal.cmd
-27Lines changed: 0 additions & 27 deletions
This file was deleted.

‎ci/azure-pipelines-steps.yml

Copy file name to clipboardExpand all lines: ci/azure-pipelines-steps.yml
+5-2Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,12 @@ steps:
2222

2323
- script: |
2424
nuget install libpng-msvc14-x64 -ExcludeVersion -OutputDirectory "$(build.BinariesDirectory)"
25-
echo ##vso[task.setvariable variable=CL]/I$(build.BinariesDirectory)\libpng-msvc14-x64\build\native\include
26-
echo ##vso[task.setvariable variable=LINK]/LIBPATH:$(build.BinariesDirectory)\libpng-msvc14-x64\build\native\lib_release
25+
nuget install zlib-msvc14-x64 -ExcludeVersion -OutputDirectory "$(build.BinariesDirectory)"
2726
echo ##vso[task.prependpath]$(build.BinariesDirectory)\libpng-msvc14-x64\build\native\bin_release
27+
echo ##vso[task.prependpath]$(build.BinariesDirectory)\zlib-msvc14-x64\build\native\bin_release
28+
echo ##vso[task.setvariable variable=CL]/I$(build.BinariesDirectory)\libpng-msvc14-x64\build\native\include /I$(build.BinariesDirectory)\zlib-msvc14-x64\build\native\include
29+
echo ##vso[task.setvariable variable=LINK]/LIBPATH:$(build.BinariesDirectory)\libpng-msvc14-x64\build\native\lib_release /LIBPATH:$(build.BinariesDirectory)\zlib-msvc14-x64\build\native\lib_release
30+
2831
displayName: 'Install dependencies with nuget'
2932
3033
- ${{ if eq(parameters.installer, 'brew') }}:

‎setupext.py

Copy file name to clipboardExpand all lines: setupext.py
+23-2Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ 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,
154155
}
155156

156157

@@ -170,6 +171,9 @@ def write_cache(local_fn, data):
170171
lft = bool(os.environ.get('MPLLOCALFREETYPE', False))
171172
options['local_freetype'] = lft or options.get('local_freetype', False)
172173

174+
staticbuild = bool(os.environ.get('MPLSTATICBUILD', os.name == 'nt'))
175+
options['staticbuild'] = staticbuild or options.get('staticbuild', False)
176+
173177

174178
if '-q' in sys.argv or '--quiet' in sys.argv:
175179
def print_raw(*args, **kwargs): pass # Suppress our own output.
@@ -195,6 +199,23 @@ def get_buffer_hash(fd):
195199
return hasher.hexdigest()
196200

197201

202+
def deplib(libname):
203+
if sys.platform != 'win32':
204+
return libname
205+
206+
known_libs = {
207+
# TODO: support versioned libpng on build system revrite
208+
'libpng16': ('libpng16', '_static'),
209+
'z': ('zlib', 'static'),
210+
}
211+
212+
libname, static_postfix = known_libs[libname]
213+
if options['staticbuild']:
214+
libname += static_postfix
215+
216+
return libname
217+
218+
198219
@functools.lru_cache(1) # We only need to compute this once.
199220
def get_pkg_config():
200221
"""
@@ -501,7 +522,7 @@ def add_flags(self, ext):
501522
ext, 'freetype2',
502523
atleast_version='9.11.3',
503524
alt_exec=['freetype-config'],
504-
default_libraries=['freetype', 'z'])
525+
default_libraries=['freetype', deplib('z')])
505526
ext.define_macros.append(('FREETYPE_BUILD_TYPE', 'system'))
506527

507528
def do_custom_build(self):
@@ -635,7 +656,7 @@ def get_extension(self):
635656
default_libraries=(
636657
['png', 'z'] if os.name == 'posix' else
637658
# libpng upstream names their lib libpng16.lib, not png.lib.
638-
['libpng16'] if os.name == 'nt' else
659+
[deplib('libpng16'), deplib('z')] if os.name == 'nt' else
639660
[]
640661
))
641662
add_numpy_flags(ext)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.