Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: more windows build and CI changes #5629

Merged
merged 18 commits into from
Jan 26, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,5 @@ cover/
# Conda files #
###############
__conda_version__.txt
lib/png.lib
lib/z.lib
64 changes: 64 additions & 0 deletions README.win.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Building on Windows

There are a few possibilities to build matplotlib on Windows:

* Wheels via [matplotlib-winbuild](https://github.com/jbmohler/matplotlib-winbuild)
* Wheels by using conda packages
* Conda packages

## Wheel builds using conda packages

This is a wheel build, but we use conda packages to get all the requirements. The binary
requirements (png, freetype,...) are statically linked and therefore not needed during the wheel
install.

The commands below assume that you can compile a native python lib for the python version of your
choice. See [this howto](http://blog.ionelmc.ro/2014/12/21/compiling-python-extensions-on-windows/)
how to install and setup such environments. If in doubt: use python 3.5 as it mostly works
without fiddling with environment variables.

``` sh
# create a new environment with the required packages
conda create -n "matplotlib_build" python=3.4 numpy python-dateutil pyparsing pytz tornado pyqt cycler tk libpng zlib freetype
activate matplotlib_build
# this package is only available in the conda-forge channel
conda install -c conda-forge msinttypes
# for python 2.7
conda install -c conda-forge functools32

# copy the libs which have "wrong" names
set LIBRARY_LIB=%CONDA_DEFAULT_ENV%\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

# Make the header files and the rest of the static libs available during the build
# CONDA_DEFAULT_ENV is a env variable which is set to the currently active environment path
set MPLBASEDIRLIST=%CONDA_DEFAULT_ENV%\Library\;.

# build the wheel
python setup.py bdist_wheel
```

The `build_alllocal.cmd` script automates these steps if you already created and activated the conda environment.


## Conda packages

This needs a [working installed C compiler](http://blog.ionelmc.ro/2014/12/21/compiling-python-extensions-on-windows/)
for the version of python you are compiling the package for but you don't need to setup the
environment variables.

```sh
# only the first time...
conda install conda-build

# the python version you want a package for...
set CONDA_PY=3.5

# builds the package, using a clean build environment
conda build ci\conda_recipe

# install the new package
conda install --use-local matplotlib
```
115 changes: 71 additions & 44 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# With infos from
# With infos from
# http://tjelvarolsson.com/blog/how-to-continuously-test-your-python-code-on-windows-using-appveyor/
# https://packaging.python.org/en/latest/appveyor/
# https://github.com/rmcgibbo/python-appveyor-conda-example
Expand All @@ -11,33 +11,31 @@ environment:
# SDK v7.0 MSVC Express 2008's SetEnv.cmd script will fail if the
# /E:ON and /V:ON options are not enabled in the batch script intepreter
# See: http://stackoverflow.com/a/13751649/163740
CMD_IN_ENV: "cmd /E:ON /V:ON /C .\\ci\\appveyor\\run_with_env.cmd"
CMD_IN_ENV: "cmd /E:ON /V:ON /C obvci_appveyor_python_build_env.cmd"
CONDA_INSTALL_LOCN: "C:\\conda"
# Workaround for https://github.com/conda/conda-build/issues/636
PYTHONIOENCODING: "UTF-8"

matrix:
- PYTHON: "C:\\Python34_64"
PYTHON_VERSION: "3.4"
PYTHON_ARCH: "64"
CONDA_PY: "34"
CONDA_NPY: "110"

- PYTHON: "C:\\Python35_64"
PYTHON_VERSION: "3.5"
PYTHON_ARCH: "64"
CONDA_PY: "35"
CONDA_NPY: "110"

- PYTHON: "C:\\Python27_64"
PYTHON_VERSION: "2.7"
PYTHON_ARCH: "64"
# for testing purpose: numpy 1.8 on py2.7, for the rest use 1.10/latest
- TARGET_ARCH: "x86"
CONDA_PY: "27"
CONDA_NPY: "18"

- PYTHON: "C:\\Python27_32"
PYTHON_VERSION: "2.7"
PYTHON_ARCH: "32"
- TARGET_ARCH: "x64"
CONDA_PY: "27"
CONDA_NPY: "18"

PYTHON_VERSION: "2.7"
- TARGET_ARCH: "x64"
CONDA_PY: "34"
CONDA_NPY: "110"
PYTHON_VERSION: "3.4"
- TARGET_ARCH: "x64"
CONDA_PY: "35"
CONDA_NPY: "110"
PYTHON_VERSION: "3.5"


# We always use a 64-bit machine, but can build x86 distributions
# with the PYTHON_ARCH variable (which is used by CMD_IN_ENV).
platform:
Expand All @@ -47,25 +45,42 @@ platform:
build: false

init:
- "ECHO %PYTHON_VERSION% %PYTHON%"
- cmd: "ECHO %PYTHON_VERSION% %CONDA_INSTALL_LOCN%"

install:
- powershell .\ci\appveyor\install.ps1
- SET PATH=%PYTHON%;%PYTHON%\Scripts;%PATH%
- appveyor DownloadFile "https://raw.githubusercontent.com/pelson/Obvious-CI/master/bootstrap-obvious-ci-and-miniconda.py"
- cmd: python bootstrap-obvious-ci-and-miniconda.py %CONDA_INSTALL_LOCN% %TARGET_ARCH% %CONDA_PY:~0,1% --without-obvci
- cmd: set PATH=%CONDA_INSTALL_LOCN%;%CONDA_INSTALL_LOCN%\scripts;%PATH%;
- cmd: set PYTHONUNBUFFERED=1
- cmd: conda install -c http://conda.anaconda.org/pelson/channel/development --yes --quiet obvious-ci
- cmd: obvci_install_conda_build_tools.py
- cmd: conda config --set show_channel_urls yes
# for msinttypes
- cmd: conda config --add channels conda-forge
# this is now the downloaded conda...
- conda info -a
# same things as in tools/conda_recipe
- cmd: conda create -y -q -n test-environment python=%PYTHON_VERSION% pip setuptools numpy python-dateutil freetype=2.5 msinttypes tk pyparsing pytz tornado libpng zlib pyqt cycler nose mock

# Fix the appveyor build environment to work with conda build
# workaround for missing vcvars64.bat in py34 64bit
- cmd: copy ci\appveyor\vcvars64.bat "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64"
# workaround for conda build on py27 prefering the normal installed
# VS tools instead of the also installed Py27 VS compiler (which wouldn't need this workarounds...)
- cmd: copy "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\vcvars64.bat" "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\amd64\vcvarsamd64.bat"

# same things as the requirements in ci/conda_recipe/meta.yaml
- cmd: conda create -y -q -n test-environment python=%PYTHON_VERSION% pip setuptools numpy python-dateutil freetype msinttypes tk pyparsing pytz tornado libpng zlib pyqt cycler nose mock
- activate test-environment
# This is needed for the installer to find the dlls...
- cmd: echo %PYTHON_VERSION% %TARGET_ARCH%
- cmd: IF %PYTHON_VERSION% == 2.7 conda install -y functools32

# Let the install prefer the static builds of the libs
- set LIBRARY_LIB=%CONDA_DEFAULT_ENV%\Library\lib
- cmd: 'mkdir lib || cmd /c "exit /b 0"'
- copy %LIBRARY_LIB%\zlibstatic.lib lib\z.lib
- copy %LIBRARY_LIB%\zlibstatic.lib lib\z.lib
- copy %LIBRARY_LIB%\libpng_static.lib lib\png.lib
- set MPLBASEDIRLIST=%CONDA_DEFAULT_ENV%\Library\;.
# enables the local freetype build
- copy ci\travis\setup.cfg .
# Show the installed packages + versions
- conda list

Expand All @@ -78,27 +93,39 @@ test_script:

after_test:
# After the tests were a success, build packages (wheels and conda)

# There is a bug in wheels which prevents building wheels when the package uses namespaces
- cmd: '%CMD_IN_ENV% python setup.py bdist_wheel'
# Note also that our setup.py script, which is called by conda-build, writes
# a __conda_version__.txt file, so the version number on the binary package
# is set dynamically. This unfortunately mean that conda build --output
# doesn't really work.

# Build the wheel
# Hide the output, the copied files really clutter the build log...
- cmd: '%CMD_IN_ENV% python setup.py bdist_wheel > NUL:'

# And now the conda build after a cleanup...
# cleanup build files so that they don't pollute the conda build but keep the wheel in dist...
- cmd: git clean -d -x -f -e dist/
# cleanup the environment so that the test-environment does not leak into the conda build...
- cmd: set MPLBASEDIRLIST=
- cmd: set LIBRARY_LIB=
- cmd: deactivate
- cmd: path
- cmd: where python
- cmd: '%CMD_IN_ENV% conda config --get channels'
# we can't build conda packages on 27 due to missing functools32, which is a recent
# additional dependency for matplotlib
- cmd: if [%CONDA_PY%] NEQ [27] %CMD_IN_ENV% conda build .\ci\conda_recipe
- cmd: '%CMD_IN_ENV% conda build .\ci\conda_recipe'

# Move the conda package into the dist directory, to register it
# as an "artifact" for Appveyor.
- cmd: 'copy /Y %PYTHON%\conda-bld\win-32\*.bz2 dist || cmd /c "exit /b 0"'
- cmd: 'copy /Y %PYTHON%\conda-bld\win-64\*.bz2 dist || cmd /c "exit /b 0"'
- cmd: dir .\dist\
# as an "artifact" for Appveyor.
- cmd: 'copy /Y %CONDA_INSTALL_LOCN%\conda-bld\win-32\*.bz2 dist || cmd /c "exit /b 0"'
- cmd: 'copy /Y %CONDA_INSTALL_LOCN%\conda-bld\win-64\*.bz2 dist || cmd /c "exit /b 0"'
- cmd: dir dist\
- cmd: echo finished...

artifacts:
- path: dist\*
name: packages

- path: result_images\*
name: test result images
name: result_images
type: zip

on_failure:
- echo zipping images after a failure...
- 7z a result_images.zip result_images\ >NUL:
- appveyor PushArtifact result_images.zip
34 changes: 34 additions & 0 deletions build_alllocal.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
:: This assumes you have installed all the dependencies via conda packages:
:: # create a new environment with the required packages
:: conda create -n "matplotlib_build" python=3.4 numpy python-dateutil pyparsing pytz tornado pyqt cycler tk libpng zlib freetype
:: activate matplotlib_build
:: # this package is only available in the conda-forge channel
:: conda install -c conda-forge msinttypes
:: if you build on py2.7:
:: conda install -c conda-forge functools32

set TARGET=bdist_wheel
IF [%1]==[] (
echo Using default target: %TARGET%
) else (
set TARGET=%1
echo Using user supplied target: %TARGET%
)

IF NOT DEFINED CONDA_DEFAULT_ENV (
echo No Conda env activated: you need to create a conda env with the right packages and activate it!
GOTO:eof
)

:: copy the libs which have "wrong" names
set LIBRARY_LIB=%CONDA_DEFAULT_ENV%\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

:: Make the header files and the rest of the static libs available during the build
:: CONDA_DEFAULT_ENV is a env variable which is set to the currently active environment path
set MPLBASEDIRLIST=%CONDA_DEFAULT_ENV%\Library\;.

:: build the target
python setup.py %TARGET%
96 changes: 0 additions & 96 deletions ci/appveyor/install.ps1

This file was deleted.

Loading