diff --git a/.coveragerc b/.coveragerc index 992eafdc..ffab8979 100644 --- a/.coveragerc +++ b/.coveragerc @@ -6,7 +6,7 @@ source = skimage include = */skimage/* omit = */setup.py - */skimage/io/_plugins/tifffile.py + */skimage/external/* [report] exclude_lines = diff --git a/.travis.yml b/.travis.yml index 2b6451ca..fb99c279 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,13 +15,23 @@ python: - 3.4 before_install: - - tools/travis_setup.sh + - export DISPLAY=:99.0 + - export PYTHONWARNINGS="all" + - export WHEELHOUSE="--no-index --find-links=http://travis-wheels.scikit-image.org/" + - travis_retry tools/travis_setup.sh install: - 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 + + - travis_retry tools/travis_install_optional.sh - tools/travis_test.sh after_success: diff --git a/bento.info b/bento.info index bcec295d..7518abbc 100644 --- a/bento.info +++ b/bento.info @@ -157,9 +157,9 @@ Library: Extension: skimage.graph._ncut_cy Sources: skimage/graph/_ncut_cy.pyx - Extension: skimage.io._plugins._tifffile + Extension: skimage.external.tifffile._tifffile Sources: - skimage/io/_plugins/tifffile.c + skimage/external/tifffile/_tifffile.c Executable: skivi Module: skimage.scripts.skivi diff --git a/setup.py b/setup.py index f8169691..b4b74ab3 100755 --- a/setup.py +++ b/setup.py @@ -141,12 +141,9 @@ if __name__ == "__main__": ], configuration=configuration, - install_requires=[ - "six>=%s" % '.'.join(str(d) for d in DEPENDENCIES['six']) - ], packages=setuptools.find_packages(exclude=['doc']), include_package_data=True, - zip_safe=False, # the package can run out of an .egg file + zip_safe=False, # the package can run out of an .egg file entry_points={ 'console_scripts': ['skivi = skimage.scripts.skivi:main'], diff --git a/skimage/io/LICENSE.txt b/skimage/external/LICENSE.txt similarity index 91% rename from skimage/io/LICENSE.txt rename to skimage/external/LICENSE.txt index 16672bcb..d9f04072 100644 --- a/skimage/io/LICENSE.txt +++ b/skimage/external/LICENSE.txt @@ -1,5 +1,5 @@ -_plugins.tifffile.py +tifffile Copyright (c) 2008-2014, Christoph Gohlke Copyright (c) 2008-2014, The Regents of the University of California diff --git a/skimage/external/__init__.py b/skimage/external/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/skimage/external/setup.py b/skimage/external/setup.py new file mode 100644 index 00000000..343c4d54 --- /dev/null +++ b/skimage/external/setup.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python + +import os.path + +base_path = os.path.abspath(os.path.dirname(__file__)) + + +def configuration(parent_package='', top_path=None): + from numpy.distutils.misc_util import Configuration, get_numpy_include_dirs + + config = Configuration('external', parent_package, top_path) + + config.add_extension('tifffile._tifffile', + sources=['tifffile/tifffile.c'], + include_dirs=[get_numpy_include_dirs()]) + return config + +if __name__ == '__main__': + from numpy.distutils.core import setup + setup(maintainer='scikit-image Developers', + maintainer_email='scikit-image@googlegroups.com', + description='External Libaries', + url='https://github.com/scikit-image/scikit-image', + license='Modified BSD', + **(configuration(top_path='').todict()) + ) diff --git a/skimage/external/tifffile/__init__.py b/skimage/external/tifffile/__init__.py new file mode 100644 index 00000000..bd426a3b --- /dev/null +++ b/skimage/external/tifffile/__init__.py @@ -0,0 +1,4 @@ +try: + from tifffile import imread, imsave, TiffFile +except ImportError: + from .tifffile_local import imread, imsave, TiffFile diff --git a/skimage/io/_plugins/tifffile.c b/skimage/external/tifffile/tifffile.c similarity index 100% rename from skimage/io/_plugins/tifffile.c rename to skimage/external/tifffile/tifffile.c diff --git a/skimage/io/_plugins/tifffile.py b/skimage/external/tifffile/tifffile_local.py similarity index 99% rename from skimage/io/_plugins/tifffile.py rename to skimage/external/tifffile/tifffile_local.py index 11744289..b5a67ccf 100644 --- a/skimage/io/_plugins/tifffile.py +++ b/skimage/external/tifffile/tifffile_local.py @@ -151,15 +151,9 @@ from xml.etree import cElementTree as etree import numpy -try: - from . import _tifffile -except ImportError: - warnings.warn( - "failed to import the optional _tifffile C extension module.\n" - "Loading of some compressed images will be slow.\n" - "Tifffile.c can be obtained at http://www.lfd.uci.edu/~gohlke/") +from . import _tifffile -__version__ = '2014.08.24' +__version__ = '0.3.3' __docformat__ = 'restructuredtext en' __all__ = ('imsave', 'imread', 'imshow', 'TiffFile', 'TiffWriter', 'TiffSequence') @@ -187,7 +181,7 @@ def imsave(filename, data, **kwargs): Examples -------- >>> data = numpy.random.rand(2, 5, 3, 301, 219) - >>> description = u'{"shape": %s}' % str(list(data.shape)) + >>> description = '{"shape": %s}' % str(list(data.shape)) >>> imsave('temp.tif', data, compress=6, ... extratags=[(270, 's', 0, description, True)]) @@ -669,12 +663,12 @@ def imread(files, **kwargs): Examples -------- - >>> im = imread('test.tif', key=0) + >>> im = imread('temp.tif', key=0) >>> im.shape - (256, 256, 4) - >>> ims = imread(['test.tif', 'test.tif']) + (3, 301, 219) + >>> ims = imread(['temp.tif', 'temp.tif']) >>> ims.shape - (2, 256, 256, 4) + (2, 10, 3, 301, 219) """ kwargs_file = {} @@ -739,10 +733,10 @@ class TiffFile(object): Examples -------- - >>> with TiffFile('test.tif') as tif: + >>> with TiffFile('temp.tif') as tif: ... data = tif.asarray() ... data.shape - (256, 256, 4) + (5, 301, 219) """ def __init__(self, arg, name=None, offset=None, size=None, @@ -2221,11 +2215,11 @@ class TiffSequence(object): Examples -------- - >>> tifs = TiffSequence("test.oif.files/*.tif") - >>> tifs.shape, tifs.axes + >>> tifs = TiffSequence("test.oif.files/*.tif") # doctest: +SKIP + >>> tifs.shape, tifs.axes # doctest: +SKIP ((2, 100), 'CT') - >>> data = tifs.asarray() - >>> data.shape + >>> data = tifs.asarray() # doctest: +SKIP + >>> data.shape # doctest: +SKIP (2, 100, 256, 256) """ @@ -3454,7 +3448,7 @@ def stripnull(string): Clean NULL terminated C strings. - >>> stripnull(b'string\\x00') + >>> stripnull(b'string\\x00') # doctest: +SKIP b'string' """ @@ -3467,9 +3461,9 @@ def stripascii(string): Clean NULL separated and terminated TIFF strings. - >>> stripascii(b'string\\x00string\\n\\x01\\x00') + >>> stripascii(b'string\\x00string\\n\\x01\\x00') # doctest: +SKIP b'string\\x00string\\n' - >>> stripascii(b'\\x00') + >>> stripascii(b'\\x00') # doctest: +SKIP b'' """ diff --git a/skimage/io/_plugins/pil_plugin.py b/skimage/io/_plugins/pil_plugin.py index a23050db..fcc26e9e 100644 --- a/skimage/io/_plugins/pil_plugin.py +++ b/skimage/io/_plugins/pil_plugin.py @@ -14,7 +14,7 @@ except ImportError: from skimage.util import img_as_ubyte, img_as_uint from six import string_types -from .tifffile import imread as tif_imread, imsave as tif_imsave +from skimage.external.tifffile import imread as tif_imread, imsave as tif_imsave def imread(fname, dtype=None): diff --git a/skimage/io/_plugins/tifffile_plugin.py b/skimage/io/_plugins/tifffile_plugin.py index fb0494c4..efdddf1b 100644 --- a/skimage/io/_plugins/tifffile_plugin.py +++ b/skimage/io/_plugins/tifffile_plugin.py @@ -1,6 +1 @@ -try: - from .tifffile import imread, imsave -except ImportError: - raise ImportError("The tifffile module could not be found.\n" - "It can be obtained at " - "\n") +from skimage.external.tifffile import imread, imsave diff --git a/skimage/io/setup.py b/skimage/io/setup.py index dbe7e940..4e3c09c3 100644 --- a/skimage/io/setup.py +++ b/skimage/io/setup.py @@ -27,10 +27,6 @@ def configuration(parent_package='', top_path=None): sources=['_plugins/_histograms.c'], include_dirs=[get_numpy_include_dirs()]) - config.add_extension('_plugins._tifffile', - sources=['_plugins/tifffile.c'], - include_dirs=[get_numpy_include_dirs()]) - return config if __name__ == '__main__': diff --git a/skimage/setup.py b/skimage/setup.py index 962adb97..9a8c8ac2 100644 --- a/skimage/setup.py +++ b/skimage/setup.py @@ -21,6 +21,7 @@ def configuration(parent_package='', top_path=None): config.add_subpackage('transform') config.add_subpackage('util') config.add_subpackage('segmentation') + config.add_subpackage('external') def add_test_directories(arg, dirname, fnames): if dirname.split(os.path.sep)[-1] == 'tests': diff --git a/tools/travis_install_optional.sh b/tools/travis_install_optional.sh new file mode 100755 index 00000000..9ecb9d20 --- /dev/null +++ b/tools/travis_install_optional.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash +set -ex + +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 + +else + sudo apt-get install -q libqt4-dev + pip install PySide $WHEELHOUSE + python ~/virtualenv/python${TRAVIS_PYTHON_VERSION}/bin/pyside_postinstall.py -install +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 + +pip install tifffile diff --git a/tools/travis_setup.sh b/tools/travis_setup.sh index f7602aef..f3caaa5e 100755 --- a/tools/travis_setup.sh +++ b/tools/travis_setup.sh @@ -4,8 +4,6 @@ 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 diff --git a/tools/travis_test.sh b/tools/travis_test.sh index df3a484d..dddd6d07 100755 --- a/tools/travis_test.sh +++ b/tools/travis_test.sh @@ -1,52 +1,17 @@ #!/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 @@ -75,10 +40,9 @@ 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 +TEST_ARGS='--exe -v --with-doctest' if [[ $TRAVIS_PYTHON_VERSION == 3.3 ]]; then - export TEST_ARGS="--with-cov --cover-package skimage" -else - export TEST_ARGS="" + TEST_ARGS="$TEST_ARGS --with-cov --cover-package skimage" fi -nosetests --exe -v --with-doctest $TEST_ARGS +nosetests $TEST_ARGS