diff --git a/.travis.yml b/.travis.yml index a59390c2..2b6451ca 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,99 +8,21 @@ language: python python: - - 2.6 - - "2.7_with_system_site_packages" - - 3.2 - - 3.3 - - 3.4 - -env: - WHEELHOUSE="--no-index --find-links=http://wheels.scikit-image.org/" +- 2.6 +- "2.7_with_system_site_packages" +- 3.2 +- 3.3 +- 3.4 before_install: - - export DISPLAY=:99.0 - - sh -e /etc/init.d/xvfb start - - sudo apt-get update - - - travis_retry pip install wheel flake8 coveralls nose - - travis_retry pip uninstall -y numpy - - # on Python 2.7, use the system versions of numpy, scipy, and matplotlib - # and the minimum version of cython and networkx - - if [[ $TRAVIS_PYTHON_VERSION == 2.7* ]]; then - travis_retry sudo apt-get install python-scipy python-matplotlib; - pip install https://github.com/cython/cython/archive/0.19.2.tar.gz; - pip install https://github.com/networkx/networkx/archive/networkx-1.8.tar.gz; - fi - - - travis_retry pip install -r requirements.txt $WHEELHOUSE; - - python check_bento_build.py + - tools/travis_setup.sh install: - - tools/header.py "Dependency versions" - - tools/build_versions.py - - export PYTHONWARNINGS=all - python setup.py build_ext --inplace + - python setup.py install script: - - tools/header.py "Run all tests with minimum dependencies" - - nosetests --exe -v skimage - - - tools/header.py "Pep8 and Flake tests" - - flake8 --exit-zero --exclude=test_*,six.py skimage doc/examples viewer_examples - - - tools/header.py "Install optional dependencies" - - # Install Qt and then update the Matplotlib settings - - if [[ $TRAVIS_PYTHON_VERSION == 2.7* ]]; then - sudo apt-get install -q python-qt4; - export SCI_QT_API=PyQt4; - - else - sudo apt-get install -q libqt4-dev; - travis_retry pip install PySide $WHEELHOUSE; - python ~/virtualenv/python${TRAVIS_PYTHON_VERSION}/bin/pyside_postinstall.py -install; - export SCI_QT_API=Pyside; - fi - - # Matplotlib settings - must be after we install Pyside - - export MPL_DIR=$HOME/.config/matplotlib - - mkdir -p $MPL_DIR - - touch $MPL_DIR/matplotlibrc - - "echo 'backend : Agg' > $MPL_DIR/matplotlibrc" - - "echo 'backend.qt4 : '$SCI_QT_API >> $MPL_DIR/matplotlibrc" - - # - imread does NOT support py3.2 - - if [[ $TRAVIS_PYTHON_VERSION != 3.2 ]]; then - sudo apt-get install -q libtiff4-dev libwebp-dev libpng12-dev xcftools; - travis_retry pip install imread; - fi - - # TODO: update when SimpleITK become available on py34 or hopefully pip - - if [[ $TRAVIS_PYTHON_VERSION != 3.4 ]]; then - travis_retry easy_install SimpleITK; - fi - - - travis_retry sudo apt-get install libfreeimage3 - - travis_retry pip install astropy - - - if [[ $TRAVIS_PYTHON_VERSION == 2.* ]]; then - travis_retry pip install pyamg; - fi - - - tools/header.py "Run doc examples" - - export PYTHONPATH=$(pwd):$PYTHONPATH - - for f in doc/examples/*.py; do python "$f"; if [ $? -ne 0 ]; then exit 1; fi done - - for f in doc/examples/applications/*.py; do python "$f"; if [ $? -ne 0 ]; then exit 1; fi done - - - tools/header.py "Run tests with all dependencies" - # run tests again with optional dependencies to get more coverage - # measure coverage on py3.3 - - if [[ $TRAVIS_PYTHON_VERSION == 3.3 ]]; then - nosetests --exe -v --with-doctest --with-cov --cover-package skimage; - else - nosetests --exe -v --with-doctest skimage; - fi + - tools/travis_test.sh after_success: - - coveralls; + - coveralls diff --git a/doc/travis_notes.txt b/doc/travis_notes.txt index 09d04889..37f5d4a1 100644 --- a/doc/travis_notes.txt +++ b/doc/travis_notes.txt @@ -3,28 +3,19 @@ http://lint.travis-ci.org/ is recommended elsewhere but does not give helpful error reports. - Make sure all of your "-" lines start on the same column -- Make sure all of your "if" lines are aligned with the "else" and "fi" lines -- Recommend using tab stops (but not tab chars) everywhere for alignment -- "If" blocks must be on one travis statement and have semicolons at the - end of each line: +- Use bash scripts for `before_install` and `script` or any part that + has conditional statements + - Make sure they are "executable" (chmod +x) + - Use the following header: -``` - - if [[ $TRAVIS_PYTHON_VERSION == 2.7 ]]; then - echo "2.7"; - else - echo "Not 2.7"; - end -``` + ``` + #!/usr/bin/env bash + set -ex + ``` -- "If" blocks cannot contain comments -- All travis commands are run with `eval` and quotes are taken as literal - characters unless you wrap the whole line in quotes: -`echo "hello : world"` is interpreted as `echo \"hello : world\"` -`"echo 'hello : world'"` is interpreted as `echo 'hello : world'` -`"echo 'hello : '$(MYVAR)'world'"` is interpreted as - `echo 'hello : $(MYVAR)world'` - Use `travis_retry` before a command to have it try several times before -failing (useful for installing from third party sources) +failing (useful for installing from third party sources). Note that this +command is not available within a bash script. - Feel free to cancel a build rather than waiting for it to go to completion if you have made a change to that branch. - A VM with 64bit Ubuntu 12.04 is a huge help for debugging. diff --git a/requirements.txt b/requirements.txt index 435803b9..98f3b77f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ cython>=0.19.2 -matplotlib>=1.1.1 +matplotlib>=1.1.0 numpy>=1.6.1 scipy>=0.9 six>=1.3 diff --git a/skimage/viewer/canvastools/recttool.py b/skimage/viewer/canvastools/recttool.py index 5d658533..8932e180 100644 --- a/skimage/viewer/canvastools/recttool.py +++ b/skimage/viewer/canvastools/recttool.py @@ -50,7 +50,13 @@ class RectangleTool(CanvasToolBase, RectangleSelector): props['edgecolor'] = props['facecolor'] RectangleSelector.__init__(self, self.ax, lambda *args: None, rectprops=props) - self.disconnect_events() # events are handled by the viewer + # Events are handled by the viewer + try: + self.disconnect_events() + except AttributeError: + # disconnect the events manually (hack for older mpl versions) + [self.canvas.mpl_disconnect(i) for i in range(10)] + # Alias rectangle attribute, which is initialized in RectangleSelector. self._rect = self.to_draw self._rect.set_animated(True) diff --git a/tools/travis_setup.sh b/tools/travis_setup.sh new file mode 100755 index 00000000..f7602aef --- /dev/null +++ b/tools/travis_setup.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash +set -ex + +sh -e /etc/init.d/xvfb start +sudo apt-get update + +WHEELHOUSE="--no-index --find-links=http://wheels.scikit-image.org/" + +pip install wheel flake8 coveralls nose +pip uninstall -y numpy + +# on Python 2.7, use the system versions of numpy, scipy, and matplotlib +# and the minimum version of cython and networkx +if [[ $TRAVIS_PYTHON_VERSION == 2.7* ]]; then + sudo apt-get install python-scipy python-matplotlib + pip install https://github.com/cython/cython/archive/0.19.2.tar.gz + pip install https://github.com/networkx/networkx/archive/networkx-1.8.tar.gz +fi + +pip install -r requirements.txt $WHEELHOUSE +python check_bento_build.py + +tools/header.py "Dependency versions" +tools/build_versions.py diff --git a/tools/travis_test.sh b/tools/travis_test.sh new file mode 100755 index 00000000..df3a484d --- /dev/null +++ b/tools/travis_test.sh @@ -0,0 +1,84 @@ +#!/usr/bin/env bash +set -ex + +export DISPLAY=:99.0 +export PYTHONWARNINGS="all" +WHEELHOUSE="--no-index --find-links=http://wheels.scikit-image.org/" + +tools/header.py "Run all tests with minimum dependencies" +nosetests --exe -v skimage + +tools/header.py "Pep8 and Flake tests" +flake8 --exit-zero --exclude=test_*,six.py skimage doc/examples viewer_examples + +tools/header.py "Install optional dependencies" + +# Install Qt and then update the Matplotlib settings +if [[ $TRAVIS_PYTHON_VERSION == 2.7* ]]; then + sudo apt-get install -q python-qt4 + MPL_QT_API=PyQt4 + MPL_DIR=$HOME/.matplotlib + export QT_API=pyqt + +else + sudo apt-get install -q libqt4-dev + pip install PySide $WHEELHOUSE + python ~/virtualenv/python${TRAVIS_PYTHON_VERSION}/bin/pyside_postinstall.py -install + MPL_QT_API=PySide + MPL_DIR=$HOME/.config/matplotlib + export QT_API=pyside +fi + +# imread does NOT support py3.2 +if [[ $TRAVIS_PYTHON_VERSION != 3.2 ]]; then + sudo apt-get install -q libtiff4-dev libwebp-dev libpng12-dev xcftools + pip install imread +fi + +# TODO: update when SimpleITK become available on py34 or hopefully pip +if [[ $TRAVIS_PYTHON_VERSION != 3.4 ]]; then + easy_install SimpleITK +fi + +sudo apt-get install libfreeimage3 +pip install astropy + +if [[ $TRAVIS_PYTHON_VERSION == 2.* ]]; then + pip install pyamg +fi + +# Matplotlib settings - do not show figures during doc examples +mkdir -p $MPL_DIR +touch $MPL_DIR/matplotlibrc +echo 'backend : Template' > $MPL_DIR/matplotlibrc + + +tools/header.py "Run doc examples" +for f in doc/examples/*.py; do + python "$f" + if [ $? -ne 0 ]; then + exit 1 + fi +done + +for f in doc/examples/applications/*.py; do + python "$f" + if [ $? -ne 0 ]; then + exit 1 + fi +done + +# Now configure Matplotlib to use Qt4 +echo 'backend: Agg' > $MPL_DIR/matplotlibrc +echo 'backend.qt4 : '$MPL_QT_API >> $MPL_DIR/matplotlibrc + + +tools/header.py "Run tests with all dependencies" +# run tests again with optional dependencies to get more coverage +if [[ $TRAVIS_PYTHON_VERSION == 3.3 ]]; then + export TEST_ARGS="--with-cov --cover-package skimage" +else + export TEST_ARGS="" +fi +nosetests --exe -v --with-doctest $TEST_ARGS +