|
| 1 | +# Building on Windows |
| 2 | + |
| 3 | +There are a few possibilities to build matplotlib on Windows: |
| 4 | + |
| 5 | +* Via [matplotlib-winbuild](https://github.com/jbmohler/matplotlib-winbuild) |
| 6 | +* Wheels by using conda packages |
| 7 | +* Conda packages |
| 8 | + |
| 9 | +## Wheel builds using conda packages |
| 10 | + |
| 11 | +This is a wheel build, but we use conda packages to get all the requirements. The binary |
| 12 | +requirements (png, freetype,...) are statically linked and therefore not needed during the wheel |
| 13 | +install. |
| 14 | + |
| 15 | +The commands below assume that you can compile a native python lib for the python version of your |
| 16 | +choice. See [this howto](http://blog.ionelmc.ro/2014/12/21/compiling-python-extensions-on-windows/) |
| 17 | +how to install and setup such environments. If in doubt: use python 3.5 as it mostly works |
| 18 | +without fiddling with environment variables. |
| 19 | + |
| 20 | +``` sh |
| 21 | +# create a new environment with the required packages |
| 22 | +conda create -n "matplotlib_build" python=3.4 numpy python-dateutil pyparsing pytz tornado pyqt cycler tk libpng zlib freetype |
| 23 | +activate matplotlib_build |
| 24 | +# this package is only available in the conda-forge channel |
| 25 | +conda install -c conda-forge msinttypes |
| 26 | + |
| 27 | +# copy the libs which have "wrong" names |
| 28 | +set LIBRARY_LIB=%CONDA_DEFAULT_ENV%\Library\lib |
| 29 | +mkdir lib || cmd /c "exit /b 0" |
| 30 | +copy %LIBRARY_LIB%\zlibstatic.lib lib\z.lib |
| 31 | +copy %LIBRARY_LIB%\libpng_static.lib lib\png.lib |
| 32 | + |
| 33 | +# Make the header files and the rest of the static libs available during the build |
| 34 | +# CONDA_DEFAULT_ENV is a env variable which is set to the currently active environment path |
| 35 | +set MPLBASEDIRLIST=%CONDA_DEFAULT_ENV%\Library\;. |
| 36 | + |
| 37 | +# build the wheel |
| 38 | +python setup.py bdist_wheel |
| 39 | +``` |
| 40 | + |
| 41 | + |
| 42 | +## Conda packages |
| 43 | + |
| 44 | +This needs a [working installed C compiler](http://blog.ionelmc.ro/2014/12/21/compiling-python-extensions-on-windows/) |
| 45 | +for the version of python you are compiling the package for but you don't need to setup the |
| 46 | +environment variables. |
| 47 | + |
| 48 | +```sh |
| 49 | +# only the first time... |
| 50 | +conda install conda-build |
| 51 | + |
| 52 | +# the python version you want a package for... |
| 53 | +set CONDA_PY=3.5 |
| 54 | + |
| 55 | +# builds the package, using a clean build environment |
| 56 | +conda build ci\conda_recipe |
| 57 | + |
| 58 | +# install the new package |
| 59 | +conda install --use-local matplotlib |
| 60 | +``` |
| 61 | + |
| 62 | +"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\dumpbin.exe" /dependents C:\portabel\miniconda\conda-bld\win-64\matplotlib-test-1.5.0+914.ga5b2a1f.dirty-py35_0.tar\matplotlib-test-1.5.0+914.ga5b2a1f.dirty-py35_0\Lib\site-packages\matplotlib\backends\_backend_agg.cp35-win_amd64.pyd |
0 commit comments