Skip to content
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
105 changes: 5 additions & 100 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ matrix:
- python: 3.5
env: PANDAS=pandas NOSE_ARGS=--with-coverage DELETE_FONT_CACHE=1
- python: 3.5
env: TEST_ARGS=--pep8
env: RUN_FLAKE8=true SKIP_TEST=true
- python: 3.5
env: BUILD_DOCS=true
env: BUILD_DOCS=true SKIP_TEST=true
- python: 3.5
env: USE_PYTEST=true PANDAS=pandas DELETE_FONT_CACHE=1 TEST_ARGS=
- python: "3.6-dev"
Expand All @@ -86,104 +86,9 @@ matrix:
- $HOME/.cache/matplotlib
allow_failures:
- python: "nightly"

before_install:
- |
# Install into our own pristine virtualenv
if [[ $TRAVIS_OS_NAME != 'osx' ]]; then
pip install --upgrade virtualenv
python -m virtualenv venv
source venv/bin/activate
export PATH=/usr/lib/ccache:$PATH
else
brew update
brew tap homebrew/gui
brew install python libpng ffmpeg imagemagick mplayer ccache
# We could install ghostscript and inkscape here to test svg and pdf
# but this makes the test time really long.
# brew install ghostscript inkscape
export PATH=/usr/local/opt/ccache/libexec:$PATH
fi

install:
- |
# Setup environment
ccache -s
# Upgrade pip and setuptools and wheel to get as clean an install as possible
pip install --upgrade pip
pip install --upgrade wheel
pip install --upgrade setuptools
- |
# Install dependencies from pypi
pip install $PRE python-dateutil $NUMPY pyparsing!=2.1.6 $PANDAS pep8 cycler coveralls coverage $MOCK
pip install $PRE -r doc-requirements.txt

# Install nose from a build which has partial
# support for python36 and suport for coverage output suppressing
pip install git+https://github.com/jenshnielsen/nose.git@matplotlibnose
# pytest-cov>=2.3.1 due to https://github.com/pytest-dev/pytest-cov/issues/124
pip install $PRE pytest 'pytest-cov>=2.3.1' pytest-timeout pytest-xdist pytest-faulthandler

# We manually install humor sans using the package from Ubuntu 14.10. Unfortunatly humor sans is not
# availible in the Ubuntu version used by Travis but we can manually install the deb from a later
# version since is it basically just a .ttf file
# The current Travis Ubuntu image is to old to search .local/share/fonts so we store fonts in .fonts
if [[ $BUILD_DOCS == true ]]; then
wget https://github.com/google/fonts/blob/master/ofl/felipa/Felipa-Regular.ttf?raw=true -O Felipa-Regular.ttf
wget http://mirrors.kernel.org/ubuntu/pool/universe/f/fonts-humor-sans/fonts-humor-sans_1.0-1_all.deb
mkdir -p tmp
mkdir -p ~/.fonts
dpkg -x fonts-humor-sans_1.0-1_all.deb tmp
cp tmp/usr/share/fonts/truetype/humor-sans/Humor-Sans.ttf ~/.fonts
cp Felipa-Regular.ttf ~/.fonts
fc-cache -f -v
else
# Use the special local version of freetype for testing
cp ci/travis/setup.cfg .
fi;
- |
# Install matplotlib
pip install -e .
- |

script:
# The number of processes is hardcoded, because using too many causes the
# Travis VM to run out of memory (since so many copies of inkscape and
# ghostscript are running at the same time).
- |
echo Testing import of tkagg backend
MPLBACKEND="tkagg" python -c 'import matplotlib.pyplot as plt; print(plt.get_backend())'
if [[ $BUILD_DOCS == false ]]; then
if [[ $DELETE_FONT_CACHE == 1 ]]; then
rm -rf ~/.cache/matplotlib
fi
export MPL_REPO_DIR=$PWD # needed for pep8-conformance test of the examples
if [[ $USE_PYTEST == false ]]; then
echo The following args are passed to nose $NOSE_ARGS
if [[ $TRAVIS_OS_NAME == 'osx' ]]; then
python tests.py $NOSE_ARGS $TEST_ARGS
else
gdb -return-child-result -batch -ex r -ex bt --args python $PYTHON_ARGS tests.py $NOSE_ARGS $TEST_ARGS
fi
else
echo The following args are passed to pytest $PYTEST_ARGS
py.test $PYTEST_ARGS $TEST_ARGS
fi
else
cd doc
python make.py html -n 2
# We don't build the LaTeX docs here, so linkchecker will complain
touch build/html/Matplotlib.pdf
# Linkchecker only works with python 2.7 for the time being
deactivate
source ~/virtualenv/python2.7/bin/activate
pip install pip --upgrade
# linkchecker is currently broken with requests 2.10.0 so force an earlier version
pip install $PRE requests==2.9.2 linkchecker
linkchecker build/html/index.html
fi
- rm -rf $HOME/.cache/matplotlib/tex.cache
- rm -rf $HOME/.cache/matplotlib/test_cache

install: source ci/travis/install.sh
script: source ci/travis/test_script.sh

after_failure:
- |
Expand Down
48 changes: 9 additions & 39 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
# Makefile for matplotlib

PYTHON = `which python`
VERSION = `${PYTHON} setup.py --version`
PYTHON ?= python

DISTFILES = API_CHANGES KNOWN_BUGS INSTALL README license \
CHANGELOG Makefile INTERACTIVE \
MANIFEST.in lib lib/matplotlib lib/dateutil lib/pytz examples setup.py
all: test

RELEASE = matplotlib-${VERSION}
flake8-diff:
./ci/travis/flake8_diff.sh

test:
${PYTHON} tests.py

test-coverage:
python tests.py

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be ${PYTHON} as well?


clean:
${PYTHON} setup.py clean;\
Expand All @@ -19,36 +22,3 @@ clean:
find . \( -name "#*" -o -name ".#*" -o -name ".*~" -o -name "*~" \) | xargs rm -f


release: ${DISTFILES}
rm -f MANIFEST;\
${PYTHON} license.py ${VERSION} license/LICENSE;\
${PYTHON} setup.py sdist --formats=gztar,zip;

pyback:
tar cvfz pyback.tar.gz *.py lib src examples/*.py unit/*.py


_build_osx105:
CFLAGS="-Os -arch i386 -arch ppc" LDFLAGS="-Os -arch i386 -arch ppc" python setup.py build

build_osx105:
echo "Use 'make -f fetch deps mpl_install instead'"


jdh_doc_snapshot:
git pull;\
python setup.py install --prefix=~/dev;\
cd doc;\
rm -rf build;\
python make.py clean;\
python make.py html latex sf sfpdf;


test:
${PYTHON} setup.py test


test-coverage:
${PYTHON} setup.py test --with-coverage --cover-package=matplotlib


128 changes: 128 additions & 0 deletions ci/travis/flake8_diff.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
#!/bin/bash

# This script is used in Travis to check that PRs do not add obvious
# flake8 violations. It relies on two things:
# - find common ancestor between branch and
# matplotlib/matplotlib remote
# - run flake8 --diff on the diff between the branch and the common
# ancestor
#
# Additional features:
# - the line numbers in Travis match the local branch on the PR
# author machine.
# - ./build_tools/travis/flake8_diff.sh can be run locally for quick
# turn-around

set -e
# pipefail is necessary to propagate exit codes
set -o pipefail

PROJECT=matplotlib/matplotlib
PROJECT_URL=https://github.com/$PROJECT.git

# Find the remote with the project name (upstream in most cases)
REMOTE=$(git remote -v | grep $PROJECT | cut -f1 | head -1 || echo '')

# Add a temporary remote if needed. For example this is necessary when
# Travis is configured to run in a fork. In this case 'origin' is the
# fork and not the reference repo we want to diff against.
if [[ -z "$REMOTE" ]]; then
TMP_REMOTE=tmp_reference_upstream
REMOTE=$TMP_REMOTE
git remote add $REMOTE $PROJECT_URL
fi

echo "Remotes:"
echo '--------------------------------------------------------------------------------'
git remote --verbose

# Travis does the git clone with a limited depth (50 at the time of
# writing). This may not be enough to find the common ancestor with
# $REMOTE/master so we unshallow the git checkout
if [[ -a .git/shallow ]]; then
echo -e '\nTrying to unshallow the repo:'
echo '--------------------------------------------------------------------------------'
git fetch --unshallow
fi

if [[ "$TRAVIS" == "true" ]]; then
if [[ "$TRAVIS_PULL_REQUEST" == "false" ]]
then
# In main repo, using TRAVIS_COMMIT_RANGE to test the commits
# that were pushed into a branch
if [[ "$PROJECT" == "$TRAVIS_REPO_SLUG" ]]; then
if [[ -z "$TRAVIS_COMMIT_RANGE" ]]; then
echo "New branch, no commit range from Travis so passing this test by convention"
exit 0
fi
COMMIT_RANGE=$TRAVIS_COMMIT_RANGE
fi
else
# We want to fetch the code as it is in the PR branch and not
# the result of the merge into master. This way line numbers
# reported by Travis will match with the local code.
LOCAL_BRANCH_REF=travis_pr_$TRAVIS_PULL_REQUEST
# In Travis the PR target is always origin
git fetch origin pull/$TRAVIS_PULL_REQUEST/head:refs/$LOCAL_BRANCH_REF
fi
fi

# If not using the commit range from Travis we need to find the common
# ancestor between $LOCAL_BRANCH_REF and $REMOTE/master
if [[ -z "$COMMIT_RANGE" ]]; then
if [[ -z "$LOCAL_BRANCH_REF" ]]; then
LOCAL_BRANCH_REF=$(git rev-parse --abbrev-ref HEAD)
fi
echo -e "\nLast 2 commits in $LOCAL_BRANCH_REF:"
echo '--------------------------------------------------------------------------------'
git log -2 $LOCAL_BRANCH_REF

REMOTE_MASTER_REF="$REMOTE/master"
# Make sure that $REMOTE_MASTER_REF is a valid reference
echo -e "\nFetching $REMOTE_MASTER_REF"
echo '--------------------------------------------------------------------------------'
git fetch $REMOTE master:refs/remotes/$REMOTE_MASTER_REF
LOCAL_BRANCH_SHORT_HASH=$(git rev-parse --short $LOCAL_BRANCH_REF)
REMOTE_MASTER_SHORT_HASH=$(git rev-parse --short $REMOTE_MASTER_REF)

COMMIT=$(git merge-base $LOCAL_BRANCH_REF $REMOTE_MASTER_REF) || \
echo "No common ancestor found for $(git show $LOCAL_BRANCH_REF -q) and $(git show $REMOTE_MASTER_REF -q)"

if [ -z "$COMMIT" ]; then
exit 1
fi

COMMIT_SHORT_HASH=$(git rev-parse --short $COMMIT)

echo -e "\nCommon ancestor between $LOCAL_BRANCH_REF ($LOCAL_BRANCH_SHORT_HASH)"\
"and $REMOTE_MASTER_REF ($REMOTE_MASTER_SHORT_HASH) is $COMMIT_SHORT_HASH:"
echo '--------------------------------------------------------------------------------'
git show --no-patch $COMMIT_SHORT_HASH

COMMIT_RANGE="$COMMIT_SHORT_HASH..$LOCAL_BRANCH_SHORT_HASH"

if [[ -n "$TMP_REMOTE" ]]; then
git remote remove $TMP_REMOTE
fi

else
echo "Got the commit range from Travis: $COMMIT_RANGE"
fi

echo -e '\nRunning flake8 on the diff in the range' "$COMMIT_RANGE" \
"($(git rev-list $COMMIT_RANGE | wc -l) commit(s)):"
echo '--------------------------------------------------------------------------------'

# We need the following command to exit with 0 hence the echo in case
# there is no match
MODIFIED_FILES=$(git diff --name-only $COMMIT_RANGE | \
grep -v 'doc/sphinxext/sphinx_gallery' || echo "no_match")

if [[ "$MODIFIED_FILES" == "no_match" ]]; then
echo "No file outside doc/sphinxext/sphinx_gallery has been modified"
else
# Conservative approach: diff without context so that code that
# was not changed does not create failures
git diff --unified=0 $COMMIT -- $MODIFIED_FILES | flake8 --diff --show-source
fi
echo -e "No problem detected by flake8\n"
70 changes: 70 additions & 0 deletions ci/travis/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#!/bin/bash
# This script is meant to be called by the "install" step defined in
# .travis.yml. See http://docs.travis-ci.com/ for more details.
# The behavior of the script is controlled by environment variabled defined
# in the .travis.yml in the top level folder of the project.

# License: 3-clause BSD

# Install into our own pristine virtualenv
if [[ $TRAVIS_OS_NAME != 'osx' ]]; then
pip install --upgrade virtualenv
python -m virtualenv venv
source venv/bin/activate
export PATH=/usr/lib/ccache:$PATH
else
rvm get head
brew update
brew tap homebrew/gui
brew install python libpng ffmpeg imagemagick mplayer ccache
# We could install ghostscript and inkscape here to test svg and pdf
# but this makes the test time really long.
# brew install ghostscript inkscape
export PATH=/usr/local/opt/ccache/libexec:$PATH
fi

# Setup environment
ccache -s

# Upgrade pip and setuptools and wheel to get as clean an install as possible
pip install --upgrade pip
pip install --upgrade wheel
pip install --upgrade setuptools

# Install dependencies from pypi
pip install $PRE python-dateutil $NUMPY pyparsing!=2.1.6 $PANDAS cycler coveralls coverage $MOCK

# Install nose from a build which has partial
# support for python36 and suport for coverage output suppressing
pip install git+https://github.com/jenshnielsen/nose.git@matplotlibnose

# pytest-cov>=2.3.1 due to https://github.com/pytest-dev/pytest-cov/issues/124
pip install $PRE pytest 'pytest-cov>=2.3.1' pytest-timeout pytest-xdist pytest-faulthandler

# We manually install humor sans using the package from Ubuntu 14.10.
# Unfortunately humor sans is not available in the Ubuntu version used by
# Travis but we can manually install the deb from a later version since is it
# basically just a .ttf file The current Travis Ubuntu image is to old to
# search .local/share/fonts so we store fonts in .fonts

if [[ $BUILD_DOCS == true ]]; then
pip install $PRE -r doc-requirements.txt
wget https://github.com/google/fonts/blob/master/ofl/felipa/Felipa-Regular.ttf?raw=true -O Felipa-Regular.ttf
wget http://mirrors.kernel.org/ubuntu/pool/universe/f/fonts-humor-sans/fonts-humor-sans_1.0-1_all.deb
mkdir -p tmp
mkdir -p ~/.fonts
dpkg -x fonts-humor-sans_1.0-1_all.deb tmp
cp tmp/usr/share/fonts/truetype/humor-sans/Humor-Sans.ttf ~/.fonts
cp Felipa-Regular.ttf ~/.fonts
fc-cache -f -v
else
# Use the special local version of freetype for testing
cp ci/travis/setup.cfg .
fi;

if [[ $RUN_FLAKE8 == true ]]; then
pip install flake8
else
# Install matplotlib
pip install -e .
fi;
Loading