From 2166041fee72bf2095deff1df26efb67a66695b5 Mon Sep 17 00:00:00 2001 From: arve0 Date: Mon, 25 May 2015 11:27:29 +0200 Subject: [PATCH 1/9] deps: cython not runtime, add dask, six >= 1.4 - cython is not a runtime dependency - dask is a runtime dependency - scikit-image depends on six.moves.urllib --- requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 12ce5fc6..58f28211 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ -cython>=0.21 matplotlib>=1.1.0 numpy>=1.6.1 scipy>=0.9 -six>=1.3 +six>=1.4 networkx>=1.8 pillow>=1.7.8 +dask[array]>=0.5.0 From b6aa3584394e67478907f2d2cc22b7477d037f93 Mon Sep 17 00:00:00 2001 From: arve0 Date: Mon, 25 May 2015 11:29:30 +0200 Subject: [PATCH 2/9] clean up setup.py according to 9cfaf4a - cython added to setup_requirements - setuptools will call easy_install to install it - all other build requirements, excluding numpy, will be resolved by pip - do not parse requirements.txt - requirements should be the real runtime requirements - fail gracefully when missing numpy - scipy will be resolved by pip from install_requires --- setup.py | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/setup.py b/setup.py index 8a938da5..b37c0fec 100644 --- a/setup.py +++ b/setup.py @@ -34,24 +34,10 @@ with open('skimage/__init__.py') as fid: with open('requirements.txt') as fid: INSTALL_REQUIRES = [l.strip() for l in fid.readlines() if l] -# development versions do not have the cythonized files -if VERSION.endswith('dev'): - SETUP_REQUIRES = [r for r in INSTALL_REQUIRES if r.startswith('cython')] -else: - INSTALL_REQUIRES = [r for r in INSTALL_REQUIRES - if not r.startswith('cython')] - SETUP_REQUIRES = [] - - -# list requirements for PyPI -REQUIRES = [r.replace('>=', ' (>= ') + ')' - for r in INSTALL_REQUIRES + SETUP_REQUIRES] +# requirements for those browsing PyPI +REQUIRES = [r.replace('>=', ' (>= ') + ')' for r in INSTALL_REQUIRES] REQUIRES = [r.replace('==', ' (== ') for r in REQUIRES] - - -# do not attempt to install numpy and scipy until they have eggs available -INSTALL_REQUIRES = [r for r in INSTALL_REQUIRES - if not r.startswith(('scipy', 'numpy'))] +REQUIRES = [r.replace('[array]', '') for r in REQUIRES] def configuration(parent_package='', top_path=None): @@ -73,9 +59,17 @@ def configuration(parent_package='', top_path=None): if __name__ == "__main__": - # purposely fail loudly if numpy or scipy are not available - from numpy.distutils.core import setup - import scipy + # purposely fail if numpy is not available + # other dependecies will be resolved by pip (install_requires) + try: + from numpy.distutils.core import setup + except ImportError: + print('To install scikit-image from source, you will need numpy.\n' + + 'Install numpy with pip:\n' + + 'pip install numpy\n' + 'Or use your operating system package manager. For more\n' + + 'details, see http://scikit-image.org/docs/stable/install.html') + sys.exit(1) setup( name=DISTNAME, @@ -105,8 +99,9 @@ if __name__ == "__main__": ], configuration=configuration, - setup_requires=SETUP_REQUIRES, install_requires=INSTALL_REQUIRES, + # install cython when running setup.py (source install) + setup_requires=['cython>=0.21'], requires=REQUIRES, packages=setuptools.find_packages(exclude=['doc']), include_package_data=True, From bf31af67283f89ebcf1fc09e2d61f58f82eae1a8 Mon Sep 17 00:00:00 2001 From: arve0 Date: Mon, 25 May 2015 11:31:09 +0200 Subject: [PATCH 3/9] update appveyor requirements.txt - cython 0.20 in wheel house is below scikit-image requirement (>=0.21) - cython 0.21 will be installed anyhow, save time not installing cython twice - dask[arrary] is added to /requirements.txt, and should not be needed here --- tools/appveyor/requirements.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/appveyor/requirements.txt b/tools/appveyor/requirements.txt index 58a4ecfa..f60a8b23 100644 --- a/tools/appveyor/requirements.txt +++ b/tools/appveyor/requirements.txt @@ -10,9 +10,8 @@ # wheels are preferred for a given version numpy==1.8.1 scipy==0.14.0 -cython==0.20.2 +cython>=0.21 matplotlib==1.4.2 pillow==2.6.1 -dask[array]>=0.5.0 wheel nose From c52dc414c69e140f5bf8221783f05accdb7146af Mon Sep 17 00:00:00 2001 From: arve0 Date: Mon, 25 May 2015 11:50:41 +0200 Subject: [PATCH 4/9] install binaries -> then resolve deps requirements.txt should hold all dependencies all deps are not in wheel house - first install binaries from wheel house - then install the rest of the deps --- tools/travis_before_install.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/travis_before_install.sh b/tools/travis_before_install.sh index 55e55c03..b4e9e31b 100755 --- a/tools/travis_before_install.sh +++ b/tools/travis_before_install.sh @@ -8,6 +8,7 @@ sh -e /etc/init.d/xvfb start export DISPLAY=:99.0 export PYTHONWARNINGS="all" export TEST_ARGS="--exe --ignore-files=^_test -v --with-doctest --ignore-files=^setup.py$" +export WHEELBINARIES="matplotlib numpy scipy pillow cython" retry () { @@ -36,6 +37,7 @@ if [[ $TRAVIS_PYTHON_VERSION == 2.7* ]]; then sed -i 's/cython>=/cython==/g' requirements.txt sed -i 's/networkx>=/networkx==/g' requirements.txt sed -i '/pillow/d' requirements.txt + export WHEELBINARIES=${WHEELBINARIES/pillow/} else virtualenv -p python --system-site-packages ~/venv fi @@ -52,9 +54,8 @@ if [[ $TRAVIS_PYTHON_VERSION == 3.2 ]]; then sed -i 's/matplotlib>=*.*.*/matplotlib==1.3.1/g' requirements.txt fi -retry pip install $WHEELHOUSE -r requirements.txt - -pip install 'dask[array]>=0.5.0' +retry pip install $WHEELHOUSE $WHEELBINARIES +retry pip install -r requirements.txt # clean up disk space sudo apt-get clean From d9908f74adad9cae340ff636940b4d10a4b04eae Mon Sep 17 00:00:00 2001 From: arve0 Date: Tue, 26 May 2015 01:18:54 +0200 Subject: [PATCH 5/9] trust http wheel house --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 0bd10075..95ac4994 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -37,7 +37,7 @@ install: - "python -c \"import struct; print(struct.calcsize('P') * 8)\"" # Install the build and runtime dependencies of the project. - - "%CMD_IN_ENV% pip install -v %WHEELHOUSE% -r tools/appveyor/requirements.txt" + - "%CMD_IN_ENV% pip install -v --trusted-host 28daf2247a33ed269873-7b1aad3fab3cc330e1fd9d109892382a.r6.cf2.rackcdn.com %WHEELHOUSE% -r tools/appveyor/requirements.txt" - "%CMD_IN_ENV% pip install -v -r requirements.txt" - "%CMD_IN_ENV% python setup.py bdist_wheel bdist_wininst" - ps: "ls dist" From ddedb9de0825f6ef7fa3e5c0197b6840042fcde2 Mon Sep 17 00:00:00 2001 From: arve0 Date: Wed, 27 May 2015 23:29:13 +0200 Subject: [PATCH 6/9] use travis python 2.7 and wheel house --- tools/travis_before_install.sh | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/tools/travis_before_install.sh b/tools/travis_before_install.sh index b4e9e31b..9da5f2e0 100755 --- a/tools/travis_before_install.sh +++ b/tools/travis_before_install.sh @@ -1,13 +1,15 @@ #!/usr/bin/env bash set -ex -export WHEELHOUSE="--no-index --find-links=http://travis-wheels.scikit-image.org/" +export WHEELHOUSE="--no-index --trusted-host travis-wheels.scikit-image.org \ + --find-links=http://travis-wheels.scikit-image.org/" export COVERALLS_REPO_TOKEN=7LdFN9232ZbSY3oaXHbQIzLazrSf6w2pQ export PIP_DEFAULT_TIMEOUT=60 sh -e /etc/init.d/xvfb start export DISPLAY=:99.0 export PYTHONWARNINGS="all" -export TEST_ARGS="--exe --ignore-files=^_test -v --with-doctest --ignore-files=^setup.py$" +export TEST_ARGS="--exe --ignore-files=^_test -v --with-doctest \ + --ignore-files=^setup.py$" export WHEELBINARIES="matplotlib numpy scipy pillow cython" @@ -29,20 +31,18 @@ retry () { } -# on Python 2.7, use the system versions of numpy, scipy, and matplotlib -# and the minimum version of cython and networkx +# test with minimum requirements on 2.7 if [[ $TRAVIS_PYTHON_VERSION == 2.7* ]]; then - virtualenv --system-site-packages ~/venv - sudo apt-get install python-scipy python-matplotlib python-imaging - sed -i 's/cython>=/cython==/g' requirements.txt - sed -i 's/networkx>=/networkx==/g' requirements.txt + sed -i 's/>=/==/g' requirements.txt + # PIL instead of Pillow sed -i '/pillow/d' requirements.txt - export WHEELBINARIES=${WHEELBINARIES/pillow/} -else - virtualenv -p python --system-site-packages ~/venv + export WHEELBINARIES=${WHEELBINARIES/pillow/pil} fi +# create new empty venv +virtualenv -p python ~/venv source ~/venv/bin/activate + retry pip install wheel flake8 coveralls nose # install system tk for matplotlib @@ -51,7 +51,7 @@ sudo apt-get install python-tk # on Python 3.2, use matplotlib 1.3.1 if [[ $TRAVIS_PYTHON_VERSION == 3.2 ]]; then - sed -i 's/matplotlib>=*.*.*/matplotlib==1.3.1/g' requirements.txt + sed -i 's/matplotlib>=.*/matplotlib==1.3.1/g' requirements.txt fi retry pip install $WHEELHOUSE $WHEELBINARIES From dedff0efa882a92a816492fc6bed85b5d5ea63b8 Mon Sep 17 00:00:00 2001 From: arve0 Date: Thu, 28 May 2015 14:44:00 +0200 Subject: [PATCH 7/9] smarter requirements in test env --- requirements.txt | 2 +- tools/travis_before_install.sh | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/requirements.txt b/requirements.txt index 58f28211..8b97dd4b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ matplotlib>=1.1.0 numpy>=1.6.1 -scipy>=0.9 +scipy>=0.9.0 six>=1.4 networkx>=1.8 pillow>=1.7.8 diff --git a/tools/travis_before_install.sh b/tools/travis_before_install.sh index 9da5f2e0..275e1ef5 100755 --- a/tools/travis_before_install.sh +++ b/tools/travis_before_install.sh @@ -10,8 +10,7 @@ export DISPLAY=:99.0 export PYTHONWARNINGS="all" export TEST_ARGS="--exe --ignore-files=^_test -v --with-doctest \ --ignore-files=^setup.py$" -export WHEELBINARIES="matplotlib numpy scipy pillow cython" - +WHEELBINARIES="matplotlib numpy scipy pillow cython" retry () { # https://gist.github.com/fungusakafungus/1026804 @@ -30,13 +29,15 @@ retry () { return 0 } +# add build dependencies +echo "cython>=0.21" >> requirements.txt -# test with minimum requirements on 2.7 +# test minimum requirements on 2.7 if [[ $TRAVIS_PYTHON_VERSION == 2.7* ]]; then sed -i 's/>=/==/g' requirements.txt # PIL instead of Pillow - sed -i '/pillow/d' requirements.txt - export WHEELBINARIES=${WHEELBINARIES/pillow/pil} + sed -i 's/pillow.*/pil==1.1.7/g' requirements.txt + WHEELBINARIES=${WHEELBINARIES/pillow/pil} fi # create new empty venv @@ -54,7 +55,12 @@ if [[ $TRAVIS_PYTHON_VERSION == 3.2 ]]; then sed -i 's/matplotlib>=.*/matplotlib==1.3.1/g' requirements.txt fi -retry pip install $WHEELHOUSE $WHEELBINARIES +# install wheels +for requirement in $WHEELBINARIES; do + WHEELS="$WHEELS $(grep $requirement requirements.txt)" +done +retry pip install $WHEELHOUSE $WHEELS + retry pip install -r requirements.txt # clean up disk space From 89521548a6797d0bbd0ed849f4d7e697af716574 Mon Sep 17 00:00:00 2001 From: arve0 Date: Thu, 28 May 2015 14:45:29 +0200 Subject: [PATCH 8/9] update install instructions --- DEPENDS.txt | 36 ++++---- doc/source/install.txt | 190 +++++++++++++++++++++++++++++++++-------- 2 files changed, 172 insertions(+), 54 deletions(-) diff --git a/DEPENDS.txt b/DEPENDS.txt index e66d53cc..2130e21d 100644 --- a/DEPENDS.txt +++ b/DEPENDS.txt @@ -1,32 +1,28 @@ Build Requirements ------------------ * `Python >= 2.6 `__ -* `Numpy >= 1.6 `__ +* `Numpy >= 1.6.1 `__ * `Cython >= 0.21 `__ -* `Six >=1.3 `__ - -You can use pip to automatically install the base dependencies as follows:: - - $ pip install -r requirements.txt +* `Six >=1.4 `__ +* `SciPy >=0.9 `__ Runtime requirements -------------------- -* `SciPy `__ -* `Matplotlib `__ -* `NetworkX `__ -* `Pillow `__ - (or `PIL `__) -* `dask array `__ +* `Python >= 2.6 `__ +* `Numpy >= 1.6.1 `__ +* `SciPy >= 0.9 `__ +* `Matplotlib >= 1.1.0 `__ +* `NetworkX >= 1.8 `__ +* `Six >=1.4 `__ +* `Pillow >= 1.7.8 `__ + (or `PIL `__) +* `dask[array] >= 0.5.0 `__ -Known build errors ------------------- -On Windows, the error ``Error:unable to find vcvarsall.bat`` means that -distutils is not correctly configured to use the C compiler. Modify (or create, -if not existing) the configuration file ``distutils.cfg`` (located for -example at ``C:\Python26\Lib\distutils\distutils.cfg``) to contain:: - [build] - compiler=mingw32 +You can use pip to automatically install the runtime dependencies as follows:: + + $ pip install -r requirements.txt + Optional Requirements --------------------- diff --git a/doc/source/install.txt b/doc/source/install.txt index 555ec407..5676d1b2 100644 --- a/doc/source/install.txt +++ b/doc/source/install.txt @@ -1,53 +1,153 @@ -Pre-built installation +Installing scikit-image +----------------------- +If you are on Mac OS X you're lucky, open the terminal and install +scikit-image with pip:: + + pip install scikit-image + + +For Python 3 use pip3 instead:: + + pip3 install scikit-image + + +For other systems, please read on. + + +Linux, Mac and Windows ---------------------- +An easy light weight method to get scikit-image installed on all of the most +popular operating systems is by using miniconda_. Go over and grab the +appropriate miniconda_ version for your operating system and install it. When +you have miniconda_ installed, open a terminal and install scikit-image +with conda:: -`Windows binaries -`__ -are kindly provided by Christoph Gohlke (note that, when upgrading, -you should first uninstall any older versions). + conda install scikit-image -The latest stable release is also included as part of -`Enthought Canopy `__, -`Python(x,y) `__ and -`Anaconda `__. -On Debian and Ubuntu, a Debian package ``python-skimage`` can be found in -`the Neurodebian repository `__. Follow `the -instructions `__ to -add Neurodebian to your system package manager, then look for -``python-skimage`` in the package manager. +If you prefer *not* using miniconda, find instructions for your operating +system below. -On systems that support setuptools, the package can be installed from the -`Python packaging index `__ using -:: +Windows +------- +Scikit-image comes with the Python distributions Anaconda_, +`Enthought Canopy`_ and `Python(x,y)`_. If you install any of +them, scikit-image should already be installed. - pip install -U scikit-image +.. _Anaconda: https://store.continuum.io/cshop/anaconda/ +.. _Enthought Canopy: https://www.enthought.com/products/canopy/ +.. _Python(x,y): http://code.google.com/p/pythonxy/wiki/Welcome -Installation from source ------------------------- -Obtain the source from the git-repository at -`http://github.com/scikit-image/scikit-image -`_ by running:: +If you prefer the regular Python distribution from python.org_, you can +install scikit-image manually by downloading packages. You will need numpy_, +scipy_ and the scikit-image package. You can find the packages in `Cristoph +Gohlke's`_ web page with compiled Python packages. Here is the direct link to +the `scipy section`_, `numpy section`_ and `scikit-image section`_. Make sure +you download the right version for your system. E.g. numpy for Python 3.4 64 +bit would be ``numpy‑1.9.2+mkl‑cp34‑none‑win_amd64.whl``. - git clone http://github.com/scikit-image/scikit-image.git +To install Goehlke's packages, use pip:: -in a terminal (you will need to have git installed on your machine). + pip install wheel + pip install --find-links Downloads scikit-image -If you do not have git installed, you can also download a zipball from -`https://github.com/scikit-image/scikit-image/zipball/master -`_. +Here ``--find-links Downloads`` means that pip will look for packages in the +folder named `Downloads`. Make sure that is where you saved the packages from +Goehlke. -The scikit can be installed using:: +As you see, installing scikit-image with pip requires some extra manual labor, +so using a Python distribution is recommended on Windows. - pip install . +If you have a brave soul, you can also install scikit-image on Windows by +compiling it from source:: -If you prefer, you can use it without installing, by simply adding -this path to your ``PYTHONPATH`` variable and compiling extensions -in-place:: + pip install scikit-image + + +If you experience the error ``Error:unable to find vcvarsall.bat`` it means that +distutils is not correctly configured to use the C compiler. Modify (or create, +if not existing) the configuration file ``distutils.cfg`` (located for +example at ``C:\Python26\Lib\distutils\distutils.cfg``) to contain:: + + [build] + compiler=mingw32 + +For more details on compiling in Windows, there is a lot of knowledge iterated +into the `setup of appveyor`_ (a continious integration service). + +.. _miniconda: http://conda.pydata.org/miniconda.html +.. _python.org: http://python.org/ +.. _numpy: http://www.numpy.org/ +.. _scipy: http://www.scipy.org/ +.. _Cristoph Gohlke's: http://www.lfd.uci.edu/~gohlke/pythonlibs/ +.. _numpy section: http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy +.. _scipy section: http://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy +.. _scikit-image section: http://www.lfd.uci.edu/~gohlke/pythonlibs/#scikit-image +.. _setup of appveyor: https://github.com/scikit-image/scikit-image/blob/master/appveyor.yml + + +Debian and Ubuntu +----------------- +On Debian and Ubuntu install scikit-image with:: + + sudo apt-get install python-skimage + + +Or if you use Python 3:: + + sudo apt-get install python3-skimage + + +On Ubuntu scikit-image is found in the `universe repo`_, and python-skimage can +also be found in the `Neurodebian repository`_. For using the repository +follow the `Neurodebian instructions`_ to add Neurodebian to your system +package manager. + +Ubuntu 14.04 LTS ships with version 0.9.3 of scikit-image, so if you need an +up-to-date version you must compile scikit-image yourself. First install the +dependencies:: + + sudo apt-get install python-matplotlib python-numpy python-pil python-scipy + + +or for Python 3:: + + sudo apt-get install python3-matplotlib python3-numpy python3-pil python3-scipy + + +Get compilers:: + + sudo apt-get install build-essential cython + + +Compile and install the latest stable version of scikit-image:: + + pip install scikit-image + + +.. _universe repo: https://help.ubuntu.com/community/Repositories/Ubuntu +.. _Neurodebian repository: http://neuro.debian.net/ +.. _Neurodebian instructions: http://neuro.debian.net/#how-to-use-this-repository + + +Other Unixes +------------ +Install binary packages of cython, matplotlib, numpy, pillow and scipy if they +are available in your operating system's package manager. Make sure you have +a C and C++ compilers. Then install scikit-image with pip:: + + pip install scikit-image + + +Upgrading +--------- +You can upgrade scikit-image by:: + + pip install --upgrade --no-deps scikit-image + pip install scikit-image # installs new dependencies, if changed - python setup.py build_ext -i Building with bento ------------------- @@ -73,4 +173,26 @@ From the ``scikit-image`` source directory:: Depending on file permissions, the install commands may need to be run as sudo. + +Install bleeding edge development version +----------------------------------------- + +Obtain the source from the git-repository at +http://github.com/scikit-image/scikit-image by running:: + + git clone http://github.com/scikit-image/scikit-image + +If you do not have git installed on your machine, you can also download a +zipball from https://github.com/scikit-image/scikit-image/zipball/master. + +The scikit can be installed using:: + + pip install . + +If you prefer, you can use a link instead by compiling extensions in-place:: + + python setup.py build_ext -i + pip install -e . + + .. include:: ../../DEPENDS.txt From 04cbaa15791388f80a8b525c82d20000626eb00d Mon Sep 17 00:00:00 2001 From: arve0 Date: Thu, 28 May 2015 16:06:32 +0200 Subject: [PATCH 9/9] expect PIL open fp --- skimage/io/tests/test_pil.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/skimage/io/tests/test_pil.py b/skimage/io/tests/test_pil.py index cd4e8939..e8e855d8 100644 --- a/skimage/io/tests/test_pil.py +++ b/skimage/io/tests/test_pil.py @@ -230,9 +230,9 @@ class TestSaveTIF: def roundtrip(self, dtype, x, compress): with temporary_file(suffix='.tif') as fname: if dtype == np.bool: - expected = ['low contrast'] + expected = ['low contrast|unclosed file'] else: - expected = [] + expected = ['unclosed file|\A\Z'] with expected_warnings(expected): if compress > 0: imsave(fname, x, compress=compress)