We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Inconsistent cython version requirements
## Description

setup.py requires cython >= 0.21 while skimage/_build.py requires >= 0.23.  Also, the two checks seem redundant.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `setup.py`
Content:
```
1 #! /usr/bin/env python
2 
3 descr = """Image Processing SciKit
4 
5 Image processing algorithms for SciPy, including IO, morphology, filtering,
6 warping, color manipulation, object detection, etc.
7 
8 Please refer to the online documentation at
9 http://scikit-image.org/
10 """
11 
12 DISTNAME = 'scikit-image'
13 DESCRIPTION = 'Image processing routines for SciPy'
14 LONG_DESCRIPTION = descr
15 MAINTAINER = 'Stefan van der Walt'
16 MAINTAINER_EMAIL = 'stefan@sun.ac.za'
17 URL = 'http://scikit-image.org'
18 LICENSE = 'Modified BSD'
19 DOWNLOAD_URL = 'http://github.com/scikit-image/scikit-image'
20 
21 import os
22 import sys
23 
24 import setuptools
25 from distutils.command.build_py import build_py
26 from distutils.command.sdist import sdist
27 
28 if sys.version_info[0] < 3:
29     import __builtin__ as builtins
30 else:
31     import builtins
32 
33 # This is a bit (!) hackish: we are setting a global variable so that the main
34 # skimage __init__ can detect if it is being loaded by the setup routine, to
35 # avoid attempting to load components that aren't built yet:
36 # the numpy distutils extensions that are used by scikit-image to recursively
37 # build the compiled extensions in sub-packages is based on the Python import
38 # machinery.
39 builtins.__SKIMAGE_SETUP__ = True
40 
41 
42 with open('skimage/__init__.py') as fid:
43     for line in fid:
44         if line.startswith('__version__'):
45             VERSION = line.strip().split()[-1][1:-1]
46             break
47 
48 with open('requirements.txt') as fid:
49     INSTALL_REQUIRES = [l.strip() for l in fid.readlines() if l]
50 
51 # requirements for those browsing PyPI
52 REQUIRES = [r.replace('>=', ' (>= ') + ')' for r in INSTALL_REQUIRES]
53 REQUIRES = [r.replace('==', ' (== ') for r in REQUIRES]
54 REQUIRES = [r.replace('[array]', '') for r in REQUIRES]
55 
56 
57 def configuration(parent_package='', top_path=None):
58     if os.path.exists('MANIFEST'):
59         os.remove('MANIFEST')
60 
61     from numpy.distutils.misc_util import Configuration
62     config = Configuration(None, parent_package, top_path)
63 
64     config.set_options(
65         ignore_setup_xxx_py=True,
66         assume_default_configuration=True,
67         delegate_options_to_subpackages=True,
68         quiet=True)
69 
70     config.add_subpackage('skimage')
71     config.add_data_dir('skimage/data')
72 
73     return config
74 
75 
76 if __name__ == "__main__":
77     try:
78         from numpy.distutils.core import setup
79         extra = {'configuration': configuration}
80         # Do not try and upgrade larger dependencies
81         for lib in ['scipy', 'numpy', 'matplotlib', 'pillow']:
82             try:
83                 __import__(lib)
84                 INSTALL_REQUIRES = [i for i in INSTALL_REQUIRES
85                                     if lib not in i]
86             except ImportError:
87                 pass
88     except ImportError:
89         if len(sys.argv) >= 2 and ('--help' in sys.argv[1:] or
90                                    sys.argv[1] in ('--help-commands',
91                                                    '--version',
92                                                    'clean',
93                                                    'egg_info',
94                                                    'install_egg_info',
95                                                    'rotate')):
96             # For these actions, NumPy is not required.
97             #
98             # They are required to succeed without Numpy for example when
99             # pip is used to install scikit-image when Numpy is not yet
100             # present in the system.
101             from setuptools import setup
102             extra = {}
103         else:
104             print('To install scikit-image from source, you will need numpy.\n' +
105                   'Install numpy with pip:\n' +
106                   'pip install numpy\n'
107                   'Or use your operating system package manager. For more\n' +
108                   'details, see http://scikit-image.org/docs/stable/install.html')
109             sys.exit(1)
110 
111     setup(
112         name=DISTNAME,
113         description=DESCRIPTION,
114         long_description=LONG_DESCRIPTION,
115         maintainer=MAINTAINER,
116         maintainer_email=MAINTAINER_EMAIL,
117         url=URL,
118         license=LICENSE,
119         download_url=DOWNLOAD_URL,
120         version=VERSION,
121 
122         classifiers=[
123             'Development Status :: 4 - Beta',
124             'Environment :: Console',
125             'Intended Audience :: Developers',
126             'Intended Audience :: Science/Research',
127             'License :: OSI Approved :: BSD License',
128             'Programming Language :: C',
129             'Programming Language :: Python',
130             'Programming Language :: Python :: 3',
131             'Topic :: Scientific/Engineering',
132             'Operating System :: Microsoft :: Windows',
133             'Operating System :: POSIX',
134             'Operating System :: Unix',
135             'Operating System :: MacOS',
136         ],
137         install_requires=INSTALL_REQUIRES,
138         # install cython when running setup.py (source install)
139         setup_requires=['cython>=0.21'],
140         requires=REQUIRES,
141         packages=setuptools.find_packages(exclude=['doc']),
142         include_package_data=True,
143         zip_safe=False,  # the package can run out of an .egg file
144 
145         entry_points={
146             'console_scripts': ['skivi = skimage.scripts.skivi:main'],
147         },
148 
149         cmdclass={'build_py': build_py,
150                   'sdist': sdist},
151         **extra
152     )
153
```

Path: `skimage/_build.py`
Content:
```
1 import sys
2 import os
3 import hashlib
4 from distutils.version import LooseVersion
5 
6 # WindowsError is not defined on unix systems
7 try:
8     WindowsError
9 except NameError:
10     class WindowsError(Exception):
11         pass
12 
13 
14 def cython(pyx_files, working_path=''):
15     """Use Cython to convert the given files to C.
16 
17     Parameters
18     ----------
19     pyx_files : list of str
20         The input .pyx files.
21 
22     """
23     # Do not build cython files if target is clean
24     if len(sys.argv) >= 2 and sys.argv[1] == 'clean':
25         return
26 
27     try:
28         from Cython import __version__
29         if LooseVersion(__version__) < '0.23':
30             raise RuntimeError('Cython >= 0.23 needed to build scikit-image')
31 
32         from Cython.Build import cythonize
33     except ImportError:
34         # If cython is not found, we do nothing -- the build will make use of
35         # the distributed .c files
36         print("Cython not found; falling back to pre-built %s"
37               % " ".join([f.replace('.pyx.in', 'c').replace('.pyx', '.c')
38                           for f in pyx_files]))
39     else:
40         for pyxfile in [os.path.join(working_path, f) for f in pyx_files]:
41 
42             # if the .pyx file stayed the same, we don't need to recompile
43             if not _changed(pyxfile):
44                 continue
45 
46             if pyxfile.endswith('.pyx.in'):
47                 process_tempita_pyx(pyxfile)
48                 pyxfile = pyxfile.replace('.pyx.in', '.pyx')
49 
50             cythonize(pyxfile)
51 
52 
53 def _md5sum(f):
54     m = hashlib.new('md5')
55     while True:
56         # Hash one 8096 byte block at a time
57         d = f.read(8096)
58         if not d:
59             break
60         m.update(d)
61     return m.hexdigest()
62 
63 
64 def _changed(filename):
65     """Compare the hash of a Cython file to the cached hash value on disk.
66 
67     """
68     filename_cache = filename + '.md5'
69 
70     try:
71         md5_cached = open(filename_cache, 'rb').read()
72     except IOError:
73         md5_cached = '0'
74 
75     with open(filename, 'rb') as f:
76         md5_new = _md5sum(f)
77 
78         with open(filename_cache, 'wb') as cf:
79             cf.write(md5_new.encode('utf-8'))
80 
81     return md5_cached != md5_new.encode('utf-8')
82 
83 
84 def process_tempita_pyx(fromfile):
85     try:
86         try:
87             from Cython import Tempita as tempita
88         except ImportError:
89             import tempita
90     except ImportError:
91         raise Exception('Building requires Tempita: '
92                         'pip install --user Tempita')
93     template = tempita.Template.from_filename(fromfile,
94                                               encoding=sys.getdefaultencoding())
95     pyxcontent = template.substitute()
96     if not fromfile.endswith('.pyx.in'):
97         raise ValueError("Unexpected extension of %s." % fromfile)
98 
99     pyxfile = os.path.splitext(fromfile)[0]    # split off the .in ending
100     with open(pyxfile, "w") as f:
101         f.write(pyxcontent)
102
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -135,8 +135,6 @@
             'Operating System :: MacOS',
         ],
         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,
diff --git a/skimage/_build.py b/skimage/_build.py
--- a/skimage/_build.py
+++ b/skimage/_build.py
@@ -3,6 +3,8 @@
 import hashlib
 from distutils.version import LooseVersion
 
+CYTHON_VERSION = '0.23'
+
 # WindowsError is not defined on unix systems
 try:
     WindowsError
@@ -26,16 +28,21 @@
 
     try:
         from Cython import __version__
-        if LooseVersion(__version__) < '0.23':
-            raise RuntimeError('Cython >= 0.23 needed to build scikit-image')
+        if LooseVersion(__version__) < CYTHON_VERSION:
+            raise RuntimeError('Cython >= %s needed to build scikit-image' % CYTHON_VERSION)
 
         from Cython.Build import cythonize
     except ImportError:
-        # If cython is not found, we do nothing -- the build will make use of
-        # the distributed .c files
-        print("Cython not found; falling back to pre-built %s"
-              % " ".join([f.replace('.pyx.in', 'c').replace('.pyx', '.c')
-                          for f in pyx_files]))
+        # If cython is not found, the build will make use of
+        # the distributed .c files if present
+        c_files = [f.replace('.pyx.in', '.c').replace('.pyx', '.c') for f in pyx_files]
+        for cfile in [os.path.join(working_path, f) for f in c_files]:
+            if not os.path.isfile(cfile):
+                raise RuntimeError('Cython >= %s is required to build scikit-image from git checkout' \
+                                   % CYTHON_VERSION)
+
+        print("Cython >= %s not found; falling back to pre-built %s" \
+              % (CYTHON_VERSION, " ".join(c_files)))
     else:
         for pyxfile in [os.path.join(working_path, f) for f in pyx_files]:

{"golden_diff": "diff --git a/setup.py b/setup.py\n--- a/setup.py\n+++ b/setup.py\n@@ -135,8 +135,6 @@\n             'Operating System :: MacOS',\n         ],\n         install_requires=INSTALL_REQUIRES,\n-        # install cython when running setup.py (source install)\n-        setup_requires=['cython>=0.21'],\n         requires=REQUIRES,\n         packages=setuptools.find_packages(exclude=['doc']),\n         include_package_data=True,\ndiff --git a/skimage/_build.py b/skimage/_build.py\n--- a/skimage/_build.py\n+++ b/skimage/_build.py\n@@ -3,6 +3,8 @@\n import hashlib\n from distutils.version import LooseVersion\n \n+CYTHON_VERSION = '0.23'\n+\n # WindowsError is not defined on unix systems\n try:\n     WindowsError\n@@ -26,16 +28,21 @@\n \n     try:\n         from Cython import __version__\n-        if LooseVersion(__version__) < '0.23':\n-            raise RuntimeError('Cython >= 0.23 needed to build scikit-image')\n+        if LooseVersion(__version__) < CYTHON_VERSION:\n+            raise RuntimeError('Cython >= %s needed to build scikit-image' % CYTHON_VERSION)\n \n         from Cython.Build import cythonize\n     except ImportError:\n-        # If cython is not found, we do nothing -- the build will make use of\n-        # the distributed .c files\n-        print(\"Cython not found; falling back to pre-built %s\"\n-              % \" \".join([f.replace('.pyx.in', 'c').replace('.pyx', '.c')\n-                          for f in pyx_files]))\n+        # If cython is not found, the build will make use of\n+        # the distributed .c files if present\n+        c_files = [f.replace('.pyx.in', '.c').replace('.pyx', '.c') for f in pyx_files]\n+        for cfile in [os.path.join(working_path, f) for f in c_files]:\n+            if not os.path.isfile(cfile):\n+                raise RuntimeError('Cython >= %s is required to build scikit-image from git checkout' \\\n+                                   % CYTHON_VERSION)\n+\n+        print(\"Cython >= %s not found; falling back to pre-built %s\" \\\n+              % (CYTHON_VERSION, \" \".join(c_files)))\n     else:\n         for pyxfile in [os.path.join(working_path, f) for f in pyx_files]:\n", "issue": "Inconsistent cython version requirements\n## Description\n\nsetup.py requires cython >= 0.21 while skimage/_build.py requires >= 0.23.  Also, the two checks seem redundant.\n\n", "before_files": [{"content": "#! /usr/bin/env python\n\ndescr = \"\"\"Image Processing SciKit\n\nImage processing algorithms for SciPy, including IO, morphology, filtering,\nwarping, color manipulation, object detection, etc.\n\nPlease refer to the online documentation at\nhttp://scikit-image.org/\n\"\"\"\n\nDISTNAME = 'scikit-image'\nDESCRIPTION = 'Image processing routines for SciPy'\nLONG_DESCRIPTION = descr\nMAINTAINER = 'Stefan van der Walt'\nMAINTAINER_EMAIL = 'stefan@sun.ac.za'\nURL = 'http://scikit-image.org'\nLICENSE = 'Modified BSD'\nDOWNLOAD_URL = 'http://github.com/scikit-image/scikit-image'\n\nimport os\nimport sys\n\nimport setuptools\nfrom distutils.command.build_py import build_py\nfrom distutils.command.sdist import sdist\n\nif sys.version_info[0] < 3:\n    import __builtin__ as builtins\nelse:\n    import builtins\n\n# This is a bit (!) hackish: we are setting a global variable so that the main\n# skimage __init__ can detect if it is being loaded by the setup routine, to\n# avoid attempting to load components that aren't built yet:\n# the numpy distutils extensions that are used by scikit-image to recursively\n# build the compiled extensions in sub-packages is based on the Python import\n# machinery.\nbuiltins.__SKIMAGE_SETUP__ = True\n\n\nwith open('skimage/__init__.py') as fid:\n    for line in fid:\n        if line.startswith('__version__'):\n            VERSION = line.strip().split()[-1][1:-1]\n            break\n\nwith open('requirements.txt') as fid:\n    INSTALL_REQUIRES = [l.strip() for l in fid.readlines() if l]\n\n# requirements for those browsing PyPI\nREQUIRES = [r.replace('>=', ' (>= ') + ')' for r in INSTALL_REQUIRES]\nREQUIRES = [r.replace('==', ' (== ') for r in REQUIRES]\nREQUIRES = [r.replace('[array]', '') for r in REQUIRES]\n\n\ndef configuration(parent_package='', top_path=None):\n    if os.path.exists('MANIFEST'):\n        os.remove('MANIFEST')\n\n    from numpy.distutils.misc_util import Configuration\n    config = Configuration(None, parent_package, top_path)\n\n    config.set_options(\n        ignore_setup_xxx_py=True,\n        assume_default_configuration=True,\n        delegate_options_to_subpackages=True,\n        quiet=True)\n\n    config.add_subpackage('skimage')\n    config.add_data_dir('skimage/data')\n\n    return config\n\n\nif __name__ == \"__main__\":\n    try:\n        from numpy.distutils.core import setup\n        extra = {'configuration': configuration}\n        # Do not try and upgrade larger dependencies\n        for lib in ['scipy', 'numpy', 'matplotlib', 'pillow']:\n            try:\n                __import__(lib)\n                INSTALL_REQUIRES = [i for i in INSTALL_REQUIRES\n                                    if lib not in i]\n            except ImportError:\n                pass\n    except ImportError:\n        if len(sys.argv) >= 2 and ('--help' in sys.argv[1:] or\n                                   sys.argv[1] in ('--help-commands',\n                                                   '--version',\n                                                   'clean',\n                                                   'egg_info',\n                                                   'install_egg_info',\n                                                   'rotate')):\n            # For these actions, NumPy is not required.\n            #\n            # They are required to succeed without Numpy for example when\n            # pip is used to install scikit-image when Numpy is not yet\n            # present in the system.\n            from setuptools import setup\n            extra = {}\n        else:\n            print('To install scikit-image from source, you will need numpy.\\n' +\n                  'Install numpy with pip:\\n' +\n                  'pip install numpy\\n'\n                  'Or use your operating system package manager. For more\\n' +\n                  'details, see http://scikit-image.org/docs/stable/install.html')\n            sys.exit(1)\n\n    setup(\n        name=DISTNAME,\n        description=DESCRIPTION,\n        long_description=LONG_DESCRIPTION,\n        maintainer=MAINTAINER,\n        maintainer_email=MAINTAINER_EMAIL,\n        url=URL,\n        license=LICENSE,\n        download_url=DOWNLOAD_URL,\n        version=VERSION,\n\n        classifiers=[\n            'Development Status :: 4 - Beta',\n            'Environment :: Console',\n            'Intended Audience :: Developers',\n            'Intended Audience :: Science/Research',\n            'License :: OSI Approved :: BSD License',\n            'Programming Language :: C',\n            'Programming Language :: Python',\n            'Programming Language :: Python :: 3',\n            'Topic :: Scientific/Engineering',\n            'Operating System :: Microsoft :: Windows',\n            'Operating System :: POSIX',\n            'Operating System :: Unix',\n            'Operating System :: MacOS',\n        ],\n        install_requires=INSTALL_REQUIRES,\n        # install cython when running setup.py (source install)\n        setup_requires=['cython>=0.21'],\n        requires=REQUIRES,\n        packages=setuptools.find_packages(exclude=['doc']),\n        include_package_data=True,\n        zip_safe=False,  # the package can run out of an .egg file\n\n        entry_points={\n            'console_scripts': ['skivi = skimage.scripts.skivi:main'],\n        },\n\n        cmdclass={'build_py': build_py,\n                  'sdist': sdist},\n        **extra\n    )\n", "path": "setup.py"}, {"content": "import sys\nimport os\nimport hashlib\nfrom distutils.version import LooseVersion\n\n# WindowsError is not defined on unix systems\ntry:\n    WindowsError\nexcept NameError:\n    class WindowsError(Exception):\n        pass\n\n\ndef cython(pyx_files, working_path=''):\n    \"\"\"Use Cython to convert the given files to C.\n\n    Parameters\n    ----------\n    pyx_files : list of str\n        The input .pyx files.\n\n    \"\"\"\n    # Do not build cython files if target is clean\n    if len(sys.argv) >= 2 and sys.argv[1] == 'clean':\n        return\n\n    try:\n        from Cython import __version__\n        if LooseVersion(__version__) < '0.23':\n            raise RuntimeError('Cython >= 0.23 needed to build scikit-image')\n\n        from Cython.Build import cythonize\n    except ImportError:\n        # If cython is not found, we do nothing -- the build will make use of\n        # the distributed .c files\n        print(\"Cython not found; falling back to pre-built %s\"\n              % \" \".join([f.replace('.pyx.in', 'c').replace('.pyx', '.c')\n                          for f in pyx_files]))\n    else:\n        for pyxfile in [os.path.join(working_path, f) for f in pyx_files]:\n\n            # if the .pyx file stayed the same, we don't need to recompile\n            if not _changed(pyxfile):\n                continue\n\n            if pyxfile.endswith('.pyx.in'):\n                process_tempita_pyx(pyxfile)\n                pyxfile = pyxfile.replace('.pyx.in', '.pyx')\n\n            cythonize(pyxfile)\n\n\ndef _md5sum(f):\n    m = hashlib.new('md5')\n    while True:\n        # Hash one 8096 byte block at a time\n        d = f.read(8096)\n        if not d:\n            break\n        m.update(d)\n    return m.hexdigest()\n\n\ndef _changed(filename):\n    \"\"\"Compare the hash of a Cython file to the cached hash value on disk.\n\n    \"\"\"\n    filename_cache = filename + '.md5'\n\n    try:\n        md5_cached = open(filename_cache, 'rb').read()\n    except IOError:\n        md5_cached = '0'\n\n    with open(filename, 'rb') as f:\n        md5_new = _md5sum(f)\n\n        with open(filename_cache, 'wb') as cf:\n            cf.write(md5_new.encode('utf-8'))\n\n    return md5_cached != md5_new.encode('utf-8')\n\n\ndef process_tempita_pyx(fromfile):\n    try:\n        try:\n            from Cython import Tempita as tempita\n        except ImportError:\n            import tempita\n    except ImportError:\n        raise Exception('Building requires Tempita: '\n                        'pip install --user Tempita')\n    template = tempita.Template.from_filename(fromfile,\n                                              encoding=sys.getdefaultencoding())\n    pyxcontent = template.substitute()\n    if not fromfile.endswith('.pyx.in'):\n        raise ValueError(\"Unexpected extension of %s.\" % fromfile)\n\n    pyxfile = os.path.splitext(fromfile)[0]    # split off the .in ending\n    with open(pyxfile, \"w\") as f:\n        f.write(pyxcontent)\n", "path": "skimage/_build.py"}], "after_files": [{"content": "#! /usr/bin/env python\n\ndescr = \"\"\"Image Processing SciKit\n\nImage processing algorithms for SciPy, including IO, morphology, filtering,\nwarping, color manipulation, object detection, etc.\n\nPlease refer to the online documentation at\nhttp://scikit-image.org/\n\"\"\"\n\nDISTNAME = 'scikit-image'\nDESCRIPTION = 'Image processing routines for SciPy'\nLONG_DESCRIPTION = descr\nMAINTAINER = 'Stefan van der Walt'\nMAINTAINER_EMAIL = 'stefan@sun.ac.za'\nURL = 'http://scikit-image.org'\nLICENSE = 'Modified BSD'\nDOWNLOAD_URL = 'http://github.com/scikit-image/scikit-image'\n\nimport os\nimport sys\n\nimport setuptools\nfrom distutils.command.build_py import build_py\nfrom distutils.command.sdist import sdist\n\nif sys.version_info[0] < 3:\n    import __builtin__ as builtins\nelse:\n    import builtins\n\n# This is a bit (!) hackish: we are setting a global variable so that the main\n# skimage __init__ can detect if it is being loaded by the setup routine, to\n# avoid attempting to load components that aren't built yet:\n# the numpy distutils extensions that are used by scikit-image to recursively\n# build the compiled extensions in sub-packages is based on the Python import\n# machinery.\nbuiltins.__SKIMAGE_SETUP__ = True\n\n\nwith open('skimage/__init__.py') as fid:\n    for line in fid:\n        if line.startswith('__version__'):\n            VERSION = line.strip().split()[-1][1:-1]\n            break\n\nwith open('requirements.txt') as fid:\n    INSTALL_REQUIRES = [l.strip() for l in fid.readlines() if l]\n\n# requirements for those browsing PyPI\nREQUIRES = [r.replace('>=', ' (>= ') + ')' for r in INSTALL_REQUIRES]\nREQUIRES = [r.replace('==', ' (== ') for r in REQUIRES]\nREQUIRES = [r.replace('[array]', '') for r in REQUIRES]\n\n\ndef configuration(parent_package='', top_path=None):\n    if os.path.exists('MANIFEST'):\n        os.remove('MANIFEST')\n\n    from numpy.distutils.misc_util import Configuration\n    config = Configuration(None, parent_package, top_path)\n\n    config.set_options(\n        ignore_setup_xxx_py=True,\n        assume_default_configuration=True,\n        delegate_options_to_subpackages=True,\n        quiet=True)\n\n    config.add_subpackage('skimage')\n    config.add_data_dir('skimage/data')\n\n    return config\n\n\nif __name__ == \"__main__\":\n    try:\n        from numpy.distutils.core import setup\n        extra = {'configuration': configuration}\n        # Do not try and upgrade larger dependencies\n        for lib in ['scipy', 'numpy', 'matplotlib', 'pillow']:\n            try:\n                __import__(lib)\n                INSTALL_REQUIRES = [i for i in INSTALL_REQUIRES\n                                    if lib not in i]\n            except ImportError:\n                pass\n    except ImportError:\n        if len(sys.argv) >= 2 and ('--help' in sys.argv[1:] or\n                                   sys.argv[1] in ('--help-commands',\n                                                   '--version',\n                                                   'clean',\n                                                   'egg_info',\n                                                   'install_egg_info',\n                                                   'rotate')):\n            # For these actions, NumPy is not required.\n            #\n            # They are required to succeed without Numpy for example when\n            # pip is used to install scikit-image when Numpy is not yet\n            # present in the system.\n            from setuptools import setup\n            extra = {}\n        else:\n            print('To install scikit-image from source, you will need numpy.\\n' +\n                  'Install numpy with pip:\\n' +\n                  'pip install numpy\\n'\n                  'Or use your operating system package manager. For more\\n' +\n                  'details, see http://scikit-image.org/docs/stable/install.html')\n            sys.exit(1)\n\n    setup(\n        name=DISTNAME,\n        description=DESCRIPTION,\n        long_description=LONG_DESCRIPTION,\n        maintainer=MAINTAINER,\n        maintainer_email=MAINTAINER_EMAIL,\n        url=URL,\n        license=LICENSE,\n        download_url=DOWNLOAD_URL,\n        version=VERSION,\n\n        classifiers=[\n            'Development Status :: 4 - Beta',\n            'Environment :: Console',\n            'Intended Audience :: Developers',\n            'Intended Audience :: Science/Research',\n            'License :: OSI Approved :: BSD License',\n            'Programming Language :: C',\n            'Programming Language :: Python',\n            'Programming Language :: Python :: 3',\n            'Topic :: Scientific/Engineering',\n            'Operating System :: Microsoft :: Windows',\n            'Operating System :: POSIX',\n            'Operating System :: Unix',\n            'Operating System :: MacOS',\n        ],\n        install_requires=INSTALL_REQUIRES,\n        requires=REQUIRES,\n        packages=setuptools.find_packages(exclude=['doc']),\n        include_package_data=True,\n        zip_safe=False,  # the package can run out of an .egg file\n\n        entry_points={\n            'console_scripts': ['skivi = skimage.scripts.skivi:main'],\n        },\n\n        cmdclass={'build_py': build_py,\n                  'sdist': sdist},\n        **extra\n    )\n", "path": "setup.py"}, {"content": "import sys\nimport os\nimport hashlib\nfrom distutils.version import LooseVersion\n\nCYTHON_VERSION = '0.23'\n\n# WindowsError is not defined on unix systems\ntry:\n    WindowsError\nexcept NameError:\n    class WindowsError(Exception):\n        pass\n\n\ndef cython(pyx_files, working_path=''):\n    \"\"\"Use Cython to convert the given files to C.\n\n    Parameters\n    ----------\n    pyx_files : list of str\n        The input .pyx files.\n\n    \"\"\"\n    # Do not build cython files if target is clean\n    if len(sys.argv) >= 2 and sys.argv[1] == 'clean':\n        return\n\n    try:\n        from Cython import __version__\n        if LooseVersion(__version__) < CYTHON_VERSION:\n            raise RuntimeError('Cython >= %s needed to build scikit-image' % CYTHON_VERSION)\n\n        from Cython.Build import cythonize\n    except ImportError:\n        # If cython is not found, the build will make use of\n        # the distributed .c files if present\n        c_files = [f.replace('.pyx.in', '.c').replace('.pyx', '.c') for f in pyx_files]\n        for cfile in [os.path.join(working_path, f) for f in c_files]:\n            if not os.path.isfile(cfile):\n                raise RuntimeError('Cython >= %s is required to build scikit-image from git checkout' \\\n                                   % CYTHON_VERSION)\n\n        print(\"Cython >= %s not found; falling back to pre-built %s\" \\\n              % (CYTHON_VERSION, \" \".join(c_files)))\n    else:\n        for pyxfile in [os.path.join(working_path, f) for f in pyx_files]:\n\n            # if the .pyx file stayed the same, we don't need to recompile\n            if not _changed(pyxfile):\n                continue\n\n            if pyxfile.endswith('.pyx.in'):\n                process_tempita_pyx(pyxfile)\n                pyxfile = pyxfile.replace('.pyx.in', '.pyx')\n\n            cythonize(pyxfile)\n\n\ndef _md5sum(f):\n    m = hashlib.new('md5')\n    while True:\n        # Hash one 8096 byte block at a time\n        d = f.read(8096)\n        if not d:\n            break\n        m.update(d)\n    return m.hexdigest()\n\n\ndef _changed(filename):\n    \"\"\"Compare the hash of a Cython file to the cached hash value on disk.\n\n    \"\"\"\n    filename_cache = filename + '.md5'\n\n    try:\n        md5_cached = open(filename_cache, 'rb').read()\n    except IOError:\n        md5_cached = '0'\n\n    with open(filename, 'rb') as f:\n        md5_new = _md5sum(f)\n\n        with open(filename_cache, 'wb') as cf:\n            cf.write(md5_new.encode('utf-8'))\n\n    return md5_cached != md5_new.encode('utf-8')\n\n\ndef process_tempita_pyx(fromfile):\n    try:\n        try:\n            from Cython import Tempita as tempita\n        except ImportError:\n            import tempita\n    except ImportError:\n        raise Exception('Building requires Tempita: '\n                        'pip install --user Tempita')\n    template = tempita.Template.from_filename(fromfile,\n                                              encoding=sys.getdefaultencoding())\n    pyxcontent = template.substitute()\n    if not fromfile.endswith('.pyx.in'):\n        raise ValueError(\"Unexpected extension of %s.\" % fromfile)\n\n    pyxfile = os.path.splitext(fromfile)[0]    # split off the .in ending\n    with open(pyxfile, \"w\") as f:\n        f.write(pyxcontent)\n", "path": "skimage/_build.py"}]}