From 3c7798bc7bedc7c868e88ddcf605c8f128f61a90 Mon Sep 17 00:00:00 2001 From: Eric Soroos Date: Thu, 19 Jan 2017 07:54:54 -0800 Subject: [PATCH 1/4] Add prebuilt docker files to travis --- .travis.yml | 129 +++++++++++---------------------------- .travis/after_success.sh | 44 +++++++++++++ .travis/install.sh | 34 +++++++++++ .travis/script.sh | 14 +++++ 4 files changed, 126 insertions(+), 95 deletions(-) create mode 100755 .travis/after_success.sh create mode 100755 .travis/install.sh create mode 100755 .travis/script.sh diff --git a/.travis.yml b/.travis.yml index 3478d0aa0..2259fd5ea 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,49 +6,37 @@ notifications: # Run slow PyPy* first, to give them a headstart and reduce waiting time. # Run latest 3.x and 2.x next, to get quick compatibility results. # Then run the remainder. -python: - - "pypy" - - "pypy3" - - 3.6 - - 2.7 - - "2.7_with_system_site_packages" # For PyQt4 - - 3.5 - - 3.4 - - 3.3 - - nightly +matrix: + fast_finish: false + allow_failures: + - python: nightly + include: + - python: "pypy" + - python: "pypy3" + - python: '3.6' + - python: '2.7' + - env: DOCKER="alpine" + - env: DOCKER="ubuntu-trusty-x86" + - env: DOCKER="ubuntu-xenial-amd64" + - env: DOCKER="ubuntu-precise-amd64" + - python: "2.7_with_system_site_packages" # For PyQt4 + - python: '3.5' + - python: '3.4' + - python: '3.3' + dist: trusty +sudo: required + +services: + - docker + install: - - "travis_retry sudo apt-get update" - - "travis_retry sudo apt-get -qq install libfreetype6-dev liblcms2-dev python-qt4 ghostscript libffi-dev libjpeg-turbo-progs cmake imagemagick" - - "travis_retry pip install cffi" - - "travis_retry pip install nose" - - "travis_retry pip install check-manifest" - - "travis_retry pip install olefile" - # Pyroma tests sometimes hang on PyPy; skip - - if [ $TRAVIS_PYTHON_VERSION != "pypy" ]; then travis_retry pip install pyroma; fi - - - "travis_retry pip install coverage" - - # docs only on python 2.7 - - if [ "$TRAVIS_PYTHON_VERSION" == "2.7" ]; then travis_retry pip install -r requirements.txt ; fi - - # clean checkout for manifest - - mkdir /tmp/check-manifest && cp -a . /tmp/check-manifest - - # webp - - pushd depends && ./install_webp.sh && popd - - # openjpeg - - pushd depends && ./install_openjpeg.sh && popd - - # libimagequant - - pushd depends && ./install_imagequant.sh && popd - - # extra test images - - pushd depends && ./install_extra_test_images.sh && popd + - if [ "$DOCKER" == "" ]; then .travis/install.sh; fi +before_install: + - if [ "$DOCKER" ]; then docker pull pythonpillow/$DOCKER; fi before_script: # Qt needs a display for some of the tests, and it's only run on the system site packages install @@ -56,60 +44,16 @@ before_script: - "sh -e /etc/init.d/xvfb start" script: - - coverage erase - - python setup.py clean - - CFLAGS="-coverage" python setup.py build_ext --inplace - - - coverage run --append --include=PIL/* selftest.py - - coverage run --append --include=PIL/* -m nose -vx Tests/test_*.py - - pushd /tmp/check-manifest && check-manifest --ignore ".coveragerc,.editorconfig,*.yml,*.yaml,tox.ini" && popd - - # Docs - - if [ "$TRAVIS_PYTHON_VERSION" == "2.7" ]; then make install && make doccheck; fi + - | + if [ "$DOCKER" == "" ]; then + .travis/script.sh + else + docker run -v $TRAVIS_BUILD_DIR:/Pillow pythonpillow/$DOCKER + fi after_success: - # gather the coverage data - - travis_retry sudo apt-get -qq install lcov - - lcov --capture --directory . -b . --output-file coverage.info - # filter to remove system headers - - lcov --remove coverage.info '/usr/*' -o coverage.filtered.info - # convert to json - - travis_retry gem install coveralls-lcov - - coveralls-lcov -v -n coverage.filtered.info > coverage.c.json - - - coverage report - - travis_retry pip install coveralls-merge - - coveralls-merge coverage.c.json - - - travis_retry pip install pep8 pyflakes - - pep8 --statistics --count PIL/*.py - - pep8 --statistics --count Tests/*.py - - pyflakes *.py | tee >(wc -l) - - pyflakes PIL/*.py | tee >(wc -l) - - pyflakes Tests/*.py | tee >(wc -l) - - # Coverage and quality reports on just the latest diff. - # (Installation is very slow on Py3, so just do it for Py2.) - - if [ ${TRAVIS_PYTHON_VERSION:0:1} == "2" ]; then depends/diffcover-install.sh; fi - - if [ ${TRAVIS_PYTHON_VERSION:0:1} == "2" ]; then depends/diffcover-run.sh; fi - - # after_all - - | - if [ "$TRAVIS_REPO_SLUG" = "python-pillow/Pillow" ] && [ "$TRAVIS_BRANCH" = "master" ] && [ "$TRAVIS_PULL_REQUEST" = "false" ]; then - curl -Lo travis_after_all.py https://raw.github.com/dmakhno/travis_after_all/master/travis_after_all.py - python travis_after_all.py - export $(cat .to_export_back) - if [ "$BUILD_LEADER" = "YES" ]; then - if [ "$BUILD_AGGREGATE_STATUS" = "others_succeeded" ]; then - echo "All jobs succeded! Triggering macOS build..." - # Trigger a macOS build at the pillow-wheels repo - ./build_children.sh - else - echo "Some jobs failed" - fi - fi - fi - + - .travis/after_success.sh + after_failure: - | if [ "$TRAVIS_REPO_SLUG" = "python-pillow/Pillow" ] && [ "$TRAVIS_BRANCH" = "master" ] && [ "$TRAVIS_PULL_REQUEST" = "false" ]; then @@ -131,11 +75,6 @@ after_script: echo leader=$BUILD_LEADER status=$BUILD_AGGREGATE_STATUS fi -matrix: - fast_finish: true - allow_failures: - - python: nightly - env: global: # travis encrypt AUTH_TOKEN= diff --git a/.travis/after_success.sh b/.travis/after_success.sh new file mode 100755 index 000000000..64f35c9c9 --- /dev/null +++ b/.travis/after_success.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +# gather the coverage data +sudo apt-get -qq install lcov +lcov --capture --directory . -b . --output-file coverage.info +# filter to remove system headers +lcov --remove coverage.info '/usr/*' -o coverage.filtered.info +# convert to json +gem install coveralls-lcov +coveralls-lcov -v -n coverage.filtered.info > coverage.c.json + +coverage report +pip install coveralls-merge +coveralls-merge coverage.c.json + +if [ "$TRAVIS_PYTHON_VERSION" == "2.7" ]; then + pip install pep8 pyflakes + pep8 --statistics --count PIL/*.py + pep8 --statistics --count Tests/*.py + pyflakes *.py | tee >(wc -l) + pyflakes PIL/*.py | tee >(wc -l) + pyflakes Tests/*.py | tee >(wc -l) +fi + +# Coverage and quality reports on just the latest diff. +# (Installation is very slow on Py3, so just do it for Py2.) +if [ ${TRAVIS_PYTHON_VERSION:0:1} == "2" ]; then depends/diffcover-install.sh; fi +if [ ${TRAVIS_PYTHON_VERSION:0:1} == "2" ]; then depends/diffcover-run.sh; fi + +# after_all + +if [ "$TRAVIS_REPO_SLUG" = "python-pillow/Pillow" ] && [ "$TRAVIS_BRANCH" = "master" ] && [ "$TRAVIS_PULL_REQUEST" = "false" ]; then + curl -Lo travis_after_all.py https://raw.github.com/dmakhno/travis_after_all/master/travis_after_all.py + python travis_after_all.py + export $(cat .to_export_back) + if [ "$BUILD_LEADER" = "YES" ]; then + if [ "$BUILD_AGGREGATE_STATUS" = "others_succeeded" ]; then + echo "All jobs succeded! Triggering macOS build..." + # Trigger a macOS build at the pillow-wheels repo + ./build_children.sh + else + echo "Some jobs failed" + fi + fi diff --git a/.travis/install.sh b/.travis/install.sh new file mode 100755 index 000000000..4b7503bed --- /dev/null +++ b/.travis/install.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +set -e + +sudo apt-get update +sudo apt-get -qq install libfreetype6-dev liblcms2-dev\ + python-qt4 ghostscript libffi-dev libjpeg-turbo-progs cmake imagemagick +pip install cffi +pip install nose +pip install check-manifest +pip install olefile +# Pyroma tests sometimes hang on PyPy; skip +if [ "$TRAVIS_PYTHON_VERSION" != "pypy" ]; then pip install pyroma; fi + +pip install coverage + +# docs only on python 2.7 +if [ "$TRAVIS_PYTHON_VERSION" == "2.7" ]; then pip install -r requirements.txt ; fi + +# clean checkout for manifest +mkdir /tmp/check-manifest && cp -a . /tmp/check-manifest + +# webp +pushd depends && ./install_webp.sh && popd + +# openjpeg +pushd depends && ./install_openjpeg.sh && popd + +# libimagequant +pushd depends && ./install_imagequant.sh && popd + +# extra test images +pushd depends && ./install_extra_test_images.sh && popd + diff --git a/.travis/script.sh b/.travis/script.sh new file mode 100755 index 000000000..e1d522122 --- /dev/null +++ b/.travis/script.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +set -e + +coverage erase +python setup.py clean +CFLAGS="-coverage" python setup.py build_ext --inplace + +coverage run --append --include=PIL/* selftest.py +coverage run --append --include=PIL/* -m nose -vx Tests/test_*.py +pushd /tmp/check-manifest && check-manifest --ignore ".coveragerc,.editorconfig,*.yml,*.yaml,tox.ini" && popd + +# Docs +if [ "$TRAVIS_PYTHON_VERSION" == "2.7" ]; then make install && make doccheck; fi From 94cc72a2ba879592e437ec8506a2fe50f9f8777e Mon Sep 17 00:00:00 2001 From: Eric Soroos Date: Fri, 20 Jan 2017 07:50:51 -0800 Subject: [PATCH 2/4] disable tests broken on old system versions of numpy/scipy --- Tests/test_numpy.py | 7 ++++++- Tests/test_scipy.py | 8 +++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Tests/test_numpy.py b/Tests/test_numpy.py index 02ae5e50b..8a530ce1b 100644 --- a/Tests/test_numpy.py +++ b/Tests/test_numpy.py @@ -135,7 +135,12 @@ class TestNumpy(PillowTestCase): img = Image.fromarray(arr * 255).convert('1') self.assertEqual(img.mode, '1') arr_back = numpy.array(img) - numpy.testing.assert_array_equal(arr, arr_back) + # numpy 1.8 and earlier return this as a boolean. (trusty/precise) + if arr_back.dtype == numpy.bool: + arr_bool = numpy.array([[1, 0, 0, 1, 0], [0, 1, 0, 0, 0]], 'bool') + numpy.testing.assert_array_equal(arr_bool, arr_back) + else: + numpy.testing.assert_array_equal(arr, arr_back) def test_save_tiff_uint16(self): # Tests that we're getting the pixel value in the right byte order. diff --git a/Tests/test_scipy.py b/Tests/test_scipy.py index 8be16c518..1f4f016d1 100644 --- a/Tests/test_scipy.py +++ b/Tests/test_scipy.py @@ -1,10 +1,11 @@ from helper import unittest, PillowTestCase - +from distutils.version import StrictVersion try: import numpy as np from numpy.testing import assert_equal from scipy import misc + import scipy HAS_SCIPY = True except ImportError: HAS_SCIPY = False @@ -27,6 +28,11 @@ class Test_scipy_resize(PillowTestCase): im1 = misc.imresize(im, T(1.101)) self.assertEqual(im1.shape, (11, 22)) + # this test fails prior to scipy 0.14.0b1 + # https://github.com/scipy/scipy/commit/855ff1fff805fb91840cf36b7082d18565fc8352 + @unittest.skipIf(HAS_SCIPY and + (StrictVersion(scipy.__version__) < StrictVersion('0.14.0')), + "Test fails on scipy < 0.14.0") def test_imresize4(self): im = np.array([[1, 2], [3, 4]]) From 426f8d68b15dacf134881b8276b564b803c35bd8 Mon Sep 17 00:00:00 2001 From: Eric Soroos Date: Fri, 20 Jan 2017 11:34:13 -0800 Subject: [PATCH 3/4] reenable nightly, move diffcover to non-docker 2.7 build --- .travis.yml | 3 ++- .travis/after_success.sh | 12 ++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2259fd5ea..34f37b611 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,7 @@ notifications: # Then run the remainder. matrix: - fast_finish: false + fast_finish: true allow_failures: - python: nightly include: @@ -24,6 +24,7 @@ matrix: - python: '3.5' - python: '3.4' - python: '3.3' + - python: 'nightly' dist: trusty diff --git a/.travis/after_success.sh b/.travis/after_success.sh index 64f35c9c9..415224f48 100755 --- a/.travis/after_success.sh +++ b/.travis/after_success.sh @@ -13,19 +13,19 @@ coverage report pip install coveralls-merge coveralls-merge coverage.c.json -if [ "$TRAVIS_PYTHON_VERSION" == "2.7" ]; then +if [ "$TRAVIS_PYTHON_VERSION" == "2.7" ] && [ "$DOCKER" == "" ]; then pip install pep8 pyflakes pep8 --statistics --count PIL/*.py pep8 --statistics --count Tests/*.py pyflakes *.py | tee >(wc -l) pyflakes PIL/*.py | tee >(wc -l) pyflakes Tests/*.py | tee >(wc -l) -fi -# Coverage and quality reports on just the latest diff. -# (Installation is very slow on Py3, so just do it for Py2.) -if [ ${TRAVIS_PYTHON_VERSION:0:1} == "2" ]; then depends/diffcover-install.sh; fi -if [ ${TRAVIS_PYTHON_VERSION:0:1} == "2" ]; then depends/diffcover-run.sh; fi + # Coverage and quality reports on just the latest diff. + # (Installation is very slow on Py3, so just do it for Py2.) + depends/diffcover-install.sh + depends/diffcover-run.sh +fi # after_all From 02e077aa480504977a5554e7181a13547c14938f Mon Sep 17 00:00:00 2001 From: wiredfool Date: Sat, 21 Jan 2017 02:21:58 -0800 Subject: [PATCH 4/4] run pep8/pyflakes on all non-docker builds --- .travis/after_success.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis/after_success.sh b/.travis/after_success.sh index 415224f48..136dbdc8e 100755 --- a/.travis/after_success.sh +++ b/.travis/after_success.sh @@ -13,14 +13,16 @@ coverage report pip install coveralls-merge coveralls-merge coverage.c.json -if [ "$TRAVIS_PYTHON_VERSION" == "2.7" ] && [ "$DOCKER" == "" ]; then +if [ "$DOCKER" == "" ]; then pip install pep8 pyflakes pep8 --statistics --count PIL/*.py pep8 --statistics --count Tests/*.py pyflakes *.py | tee >(wc -l) pyflakes PIL/*.py | tee >(wc -l) pyflakes Tests/*.py | tee >(wc -l) +fi +if [ "$TRAVIS_PYTHON_VERSION" == "2.7" ] && [ "$DOCKER" == "" ]; then # Coverage and quality reports on just the latest diff. # (Installation is very slow on Py3, so just do it for Py2.) depends/diffcover-install.sh