10000 CI: add appveyor script to build Windows wheels by matthew-brett · Pull Request #6969 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

CI: add appveyor script to build Windows wheels #6969

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

Closed
Closed
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
185 changes: 185 additions & 0 deletions appveyor.yml
8000 8000
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
# 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

# Backslashes in quotes need to be escaped: \ -> "\\"

environment:

global:
# 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 obvci_appveyor_python_build_env.cmd"
# Workaround for https://github.com/conda/conda-build/issues/636
PYTHONIOENCODING: "UTF-8"
TEST_ARGS: --no-pep8
PYTEST_ARGS: -ra --timeout=300 --durations=25 #--cov-report= --cov=lib #-n %NUMBER_OF_PROCESSORS%
USE_PYTEST: no
#PYTHONHASHSEED: 0 # Workaround for pytest-xdist flaky colletion order
# # https://github.com/pytest-dev/pytest/issues/920
# # https://github.com/pytest-dev/pytest/issues/1075

matrix:
# for testing purpose: numpy 1.8 on py2.7, for the rest use 1.10/latest
# theoretically the CONDA_INSTALL_LOCN could be only two: one for 32bit,
# one for 64bit because we construct envs anyway. But using one for the
# right python version is hopefully making it fast due to package caching.
- TARGET_ARCH: "x64"
CONDA_PY: "27"
CONDA_NPY: "18"
PYTHON_VERSION: "2.7"
TEST_ALL: "no"
CONDA_INSTALL_LOCN: "C:\\Miniconda-x64"
- TARGET_ARCH: "x64"
CONDA_PY: "34"
CONDA_NPY: "110"
PYTHON_VERSION: "3.4"
TEST_ALL: "no"
CONDA_INSTALL_LOCN: "C:\\Miniconda3-x64"
- TARGET_ARCH: "x64"
CONDA_PY: "35"
CONDA_NPY: "110"
PYTHON_VERSION: "3.5"
TEST_ALL: "no"
CONDA_INSTALL_LOCN: "C:\\Miniconda35-x64"
- TARGET_ARCH: "x86"
CONDA_PY: "27"
CONDA_NPY: "18"
PYTHON_VERSION: "2.7"
# this variable influence pdf/svg and most importantly the latex related tests
# which triples the runtime of the tests (7-8min vs 30min).
# pick the one which seems to make the most problems and run it last, so that
# the rest of the tests can give feedback earlier
TEST_ALL: "yes"
CONDA_INSTALL_LOCN: "C:\\Miniconda"

# 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:
- x64

# all our python builds have to happen in tests_script...
build: false

init:
- cmd: "ECHO %PYTHON_VERSION% PYTEST=%USE_PYTEST% %CONDA_INSTALL_LOCN%"

install:
- cmd: set PATH=%CONDA_INSTALL_LOCN%;%CONDA_INSTALL_LOCN%\scripts;%PATH%;
- cmd: set PYTHONUNBUFFERED=1
# for obvci_appveyor_python_build_env.cmd
- cmd: conda install -c pelson/channel/development --yes --quiet obvious-ci
# for msinttypes and newer stuff
- cmd: conda config --add channels conda-forge
- cmd: conda config --set show_channel_urls yes
- cmd: conda config --set always_yes true
# For building conda packages
- cmd: conda install --yes conda-build jinja2 anaconda-client
# this is now the downloaded conda...
- conda info -a

# 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"

# For building, use a new environment which only includes the requirements for mpl
# same things as the requirements in ci/conda_recipe/meta.yaml
# if conda-forge gets a new pyqt, it might be nice to install it as well to have more backends
# https://github.com/conda-forge/conda-forge.github.io/issues/157#issuecomment-223536381
- conda create -q -n test-environment python=%PYTHON_VERSION%
pip setuptools numpy python-dateutil freetype=2.6 msinttypes "tk=8.5"
pyparsing pytz tornado "libpng>=1.6.21,<1.7" "zlib=1.2" "cycler>=0.10"
nose mock sphinx
- activate test-environment
- cmd: echo %PYTHON_VERSION% %TARGET_ARCH%
- cmd: IF %PYTHON_VERSION% == 2.7 conda install -q functools32
# pytest-cov>=2.3.1 due to https://github.com/pytest-dev/pytest-cov/issues/124
- if x%USE_PYTEST% == xyes conda install -q pytest "pytest-cov>=2.3.1" pytest-timeout #pytest-xdist

# Let the install prefer the static builds of the libs
- set LIBRARY_LIB=%CONDA_PREFIX%\Library\lib
- cmd: '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
# 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
- del %LIBRARY_LIB%\png.lib
- del %LIBRARY_LIB%\z.lib
- set MPLBASEDIRLIST=%CONDA_PREFIX%\Library\;.
# enables the local freetype build
- copy ci\travis\setup.cfg .
# Show the installed packages + versions
- conda list

test_script:
# Now build the thing..
- '%CMD_IN_ENV% python setup.py develop'
# these should show no z, png, or freetype dll...
- set "DUMPBIN=%VS140COMNTOOLS%\..\..\VC\bin\dumpbin.exe"
- cmd: '"%DUMPBIN%" /DEPENDENTS lib\matplotlib\_png*.pyd'
- cmd: '"%DUMPBIN%" /DEPENDENTS lib\matplotlib\ft2font*.pyd'
- cmd: '"%DUMPBIN%" /DEPENDENTS lib\matplotlib\ft2font*.pyd | findstr freetype.*.dll && exit /b 1 || exit /b 0'
- cmd: '"%DUMPBIN%" /DEPENDENTS lib\\matplotlib\\_png*.pyd | findstr z.*.dll && exit /b 1 || exit /b 0'
- cmd: '"%DUMPBIN%" /DEPENDENTS lib\\matplotlib\\_png*.pyd | findstr png.*.dll && exit /b 1 || exit /b 0'

# this are optional dependencies so that we don't skip so many tests...
- cmd: if x%TEST_ALL% == xyes; conda install -q pillow miktex inkscape
# missing packages on conda-forge for ffmpeg avconv mencoder imagemagick
- cmd: if x%TEST_ALL% == xyes; conda install -q -c menpo ffmpeg # a repackaged version
# This install sometimes failed randomly :-(
#- cmd: choco install imagemagick

# Test import of tkagg backend
- python -c "import matplotlib as m; m.use('tkagg'); import matplotlib.pyplot as plt; print(plt.get_backend())"
# tests
- if x%USE_PYTEST% == xyes echo The following args are passed to pytest %PYTEST_ARGS%
- if x%USE_PYTEST% == xyes py.test %PYTEST_ARGS% %TEST_ARGS%
- if x%USE_PYTEST% == xno python tests.py %TEST_ARGS%
# Generate a html for visual tests
- python visual_tests.py

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

# Build the wheel with the static libs
# Hide the output, the copied files really clutter the build log...
- cmd: '%CMD_IN_ENV% python setup.py bdist_wheel > NUL:'
# Delete the result images from the wheel
- pip install delocate
- cmd: for %%w in ("dist\*.whl") do python tools\rm_test_images.py %%w

# 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'
- cmd: '%CMD_IN_ENV% conda build -q .\ci\conda_recipe'

# Move the conda package into the dist directory, to register it
# 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: result_images
type: zip

on_failure:
- python visual_tests.py
- echo zipping images after a failure...
- 7z a result_images.zip result_images\ |grep -v "Compressing"
- 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%
1 change: 1 addition & 0 deletions ci/appveyor/vcvars64.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CALL "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /x64
3 changes: 3 additions & 0 deletions ci/conda_recipe/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# conda package

Up to now, this is mainly used to build a test conda package on windows on appveyor.
16 changes: 16 additions & 0 deletions ci/conda_recipe/bld.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
set LIBPATH=%LIBRARY_LIB%;
set INCLUDE=%INCLUDE%;%PREFIX%\Library\include\freetype2

ECHO [directories] > setup.cfg
ECHO basedirlist = %LIBRARY_PREFIX% >> setup.cfg
ECHO [packages] >> setup.cfg
ECHO tests = False >> setup.cfg
ECHO sample_data = False >> setup.cfg
ECHO toolkits_tests = False >> setup.cfg

@rem workaround for https://github.com/matplotlib/matplotlib/issues/6460
@rem see also https://github.com/conda-forge/libpng-feedstock/pull/4
copy /y %LIBRARY_LIB%\libpng16.lib %LIBRARY_LIB%\png.lib

%PYTHON% setup.py install --single-version-externally-managed --record=record.txt
if errorlevel 1 exit 1
37 changes: 37 additions & 0 deletions ci/conda_recipe/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash

if [ `uname` == Linux ]; then
pushd $PREFIX/lib
ln -s libtcl8.5.so libtcl.so
ln -s libtk8.5.so libtk.so
popd
fi

cat <<EOF > setup.cfg
[directories]
basedirlist = $PREFIX

[packages]
tests = False
toolkit_tests = False
sample_data = False

EOF

# The macosx backend isn't building with conda at this stage.
if [ `uname` == Darwin ]; then
cat << EOF >> setup.cfg

[gui_support]
tkagg = true
macosx = false

EOF
fi

cat setup.cfg
sed -i.bak "s|/usr/local|$PREFIX|" setupext.py


$PYTHON setup.py install --single-version-externally-managed --record=record.txt

13 changes: 13 additions & 0 deletions ci/conda_recipe/cfg_qt4agg.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git setup.cfg.template setup.cfg.template
index cae6f67..fd11c79 100644
--- setup.cfg.template
+++ setup.cfg.template
@@ -88,7 +88,7 @@
# if you have disabled the relevent extension modules. Agg will be used
# by default.
#
-#backend = Agg
+backend = Qt4Agg
#

[package_data]
15 changes: 15 additions & 0 deletions ci/conda_recipe/condaversion.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
diff --git setup.py setup.py
index 8af8b6d..4e4f9d2 100644
--- setup.py
+++ setup.py
@@ -57,6 +57,9 @@
import versioneer
__version__ = versioneer.get_version()

+# For conda builds...
+with open("__conda_version__.txt", "w") as f:
+ f.write(__version__)

# These are the packages in the order we want to display them. This
# list may contain strings to create section headers for the display.

73 changes: 73 additions & 0 deletions ci/conda_recipe/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Full credit goes to https://github.com/conda/conda-recipes for providing this recipe.
# It has been subsequently adapted for automated building with conda-forge and matplotlib.

package:
name: matplotlib
version: 1.9.9

source:
path: ../../

patches:
# A patch to make Qt4Agg the default backend.
- cfg_qt4agg.patch # [linux]
# Patches the matplotlibrc template to default to Qt4.
- rctmp_pyside.patch # [not osx]
# dynamic version from git
# we can't use condas usual dynamic versions as setup.py uses
# multiprocessing during the configure stage and this seems to confuse conda-build.
# https://github.com/conda/conda-build/issues/1061
- condaversion.patch

requirements:
build:
- python
- setuptools
- pkg-config # [not win]
- numpy x.x
- python-dateutil
- freetype 2.6*
- msinttypes # [win]
- cycler >=0.10
- nose
- pyparsing
- pytz
# - py2cairo # [linux and py2k]
- tornado
- libpng >=1.6.21,<1.7
- zlib 1.2* # [win]
- pyqt # [not osx]
- tk 8.5* # [linux]
- functools32 # [py2k]

run:
- python
- numpy x.x
- cycler >=0.10
- python-dateutil
- freetype 2.6*
- pytz
- pyparsing
# - py2cairo # [linux and py2k]
- libpng >=1.6.21,<1.7
- pyqt # [not osx]
- tk 8.5* # [linux and win]
- functools32 # [py2k]

test:
imports:
- matplotlib
- matplotlib.pyplot

about:
home: http://matplotlib.org/
license: PSF-based (http://matplotlib.org/users/license.html)
summary: Publication quality figures in Python

extra:
recipe-maintainers:
- janschulz # only in the mpl repository
- mdboom # rest form conda-forge
- ocefpaf
- pelson
- tacaswell
Loading
0