We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Reduce the wheel size relative to 0.19.0 for upcoming releases
## Description

Continuing the discussion from https://github.com/scikit-image/scikit-image/issues/6086#issuecomment-986063471

We have seen a recent increase in wheel size by nearly a factor of two for 0.19.0 vs. 0.18.3. In order to be a good citizen, preserving PyPI and CI resources we should try to reduce this if possible.

So far, one difference I noticed was that the 0.19.0 wheels have various `.c`, `.cpp` and `.pyx` files that should not need to be in the wheel. 



--- 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 import os
4 import sys
5 import tempfile
6 import shutil
7 import builtins
8 import textwrap
9 from numpy.distutils.command.build_ext import build_ext as npy_build_ext
10 
11 import setuptools
12 from setuptools.command.build_py import build_py
13 from setuptools.command.sdist import sdist
14 try:
15     from setuptools.errors import CompileError, LinkError
16 except ImportError:
17     # can remove this except case once we require setuptools>=59.0
18     from distutils.errors import CompileError, LinkError
19 
20 from pythran.dist import PythranBuildExt as pythran_build_ext
21 
22 DISTNAME = 'scikit-image'
23 DESCRIPTION = 'Image processing in Python'
24 MAINTAINER = 'Stefan van der Walt'
25 MAINTAINER_EMAIL = 'stefan@sun.ac.za'
26 URL = 'https://scikit-image.org'
27 LICENSE = 'Modified BSD'
28 DOWNLOAD_URL = 'https://scikit-image.org/docs/stable/install.html'
29 PROJECT_URLS = {
30     "Bug Tracker": 'https://github.com/scikit-image/scikit-image/issues',
31     "Documentation": 'https://scikit-image.org/docs/stable/',
32     "Source Code": 'https://github.com/scikit-image/scikit-image'
33 }
34 
35 with open('README.md', encoding='utf-8') as f:
36     LONG_DESCRIPTION = f.read()
37 
38 if sys.version_info < (3, 8):
39 
40     error = """Python {py} detected.
41 
42 scikit-image supports only Python 3.8 and above.
43 
44 For Python 2.7, please install the 0.14.x Long Term Support release using:
45 
46  $ pip install 'scikit-image<0.15'
47 """.format(py='.'.join([str(v) for v in sys.version_info[:3]]))
48 
49     sys.stderr.write(error + "\n")
50     sys.exit(1)
51 
52 # This is a bit (!) hackish: we are setting a global variable so that the main
53 # skimage __init__ can detect if it is being loaded by the setup routine, to
54 # avoid attempting to load components that aren't built yet:
55 # the numpy distutils extensions that are used by scikit-image to recursively
56 # build the compiled extensions in sub-packages is based on the Python import
57 # machinery.
58 builtins.__SKIMAGE_SETUP__ = True
59 
60 
61 # Support for openmp
62 
63 class ConditionalOpenMP(pythran_build_ext[npy_build_ext]):
64 
65     def can_compile_link(self, compile_flags, link_flags):
66 
67         if "PYODIDE_PACKAGE_ABI" in os.environ:
68             # pyodide doesn't support OpenMP
69             return False
70 
71         cc = self.compiler
72         fname = 'test.c'
73         cwd = os.getcwd()
74         tmpdir = tempfile.mkdtemp()
75 
76         code = ("#include <omp.h>"
77                 "int main(int argc, char** argv) { return(0); }")
78 
79         if self.compiler.compiler_type == "msvc":
80             # make sure we build a DLL on Windows
81             local_link_flags = link_flags + ["/DLL"]
82         else:
83             local_link_flags = link_flags
84 
85         try:
86             os.chdir(tmpdir)
87             with open(fname, 'wt') as fobj:
88                 fobj.write(code)
89             try:
90                 objects = cc.compile([fname],
91                                      extra_postargs=compile_flags)
92             except CompileError:
93                 return False
94             try:
95                 # Link shared lib rather then executable to avoid
96                 # http://bugs.python.org/issue4431 with MSVC 10+
97                 cc.link_shared_lib(objects, "testlib",
98                                    extra_postargs=local_link_flags)
99             except (LinkError, TypeError):
100                 return False
101         finally:
102             os.chdir(cwd)
103             shutil.rmtree(tmpdir)
104         return True
105 
106     def build_extensions(self):
107         """ Hook into extension building to set compiler flags """
108 
109         compile_flags = list()
110         link_flags = list()
111 
112         # check which compiler is being used
113         if self.compiler.compiler_type == "msvc":
114             # '-fopenmp' is called '/openmp' in msvc
115             compile_flags += ['/openmp']
116         else:
117             compile_flags += ['-fopenmp']
118             link_flags += ['-fopenmp']
119 
120         if self.can_compile_link(compile_flags, link_flags):
121             for ext in self.extensions:
122                 ext.extra_compile_args += compile_flags
123                 ext.extra_link_args += link_flags
124 
125         super(ConditionalOpenMP, self).build_extensions()
126 
127 
128 with open('skimage/__init__.py', encoding='utf-8') as fid:
129     for line in fid:
130         if line.startswith('__version__'):
131             VERSION = line.strip().split()[-1][1:-1]
132             break
133 
134 
135 def parse_requirements_file(filename):
136     with open(filename, encoding='utf-8') as fid:
137         requires = [line.strip() for line in fid.readlines() if line]
138 
139     return requires
140 
141 
142 INSTALL_REQUIRES = parse_requirements_file('requirements/default.txt')
143 # The `requirements/extras.txt` file is explicitely omitted because
144 # it contains requirements that do not have wheels uploaded to pip
145 # for the platforms we wish to support.
146 extras_require = {
147     dep: parse_requirements_file('requirements/' + dep + '.txt')
148     for dep in ['docs', 'optional', 'test', 'data']
149 }
150 
151 
152 def configuration(parent_package='', top_path=None):
153     if os.path.exists('MANIFEST'):
154         os.remove('MANIFEST')
155 
156     from numpy.distutils.misc_util import Configuration
157     config = Configuration(None, parent_package, top_path)
158 
159     config.set_options(
160         ignore_setup_xxx_py=True,
161         assume_default_configuration=True,
162         delegate_options_to_subpackages=True,
163         quiet=True)
164 
165     config.add_subpackage('skimage')
166 
167     return config
168 
169 
170 if __name__ == "__main__":
171     cmdclass = {'build_py': build_py,
172                 'sdist': sdist}
173     try:
174         # test if build dependencies exist.
175         # if not, some commands are still viable.
176         # note: this must be kept in sync with pyproject.toml
177         from numpy.distutils.core import setup
178         import cython
179         extra = {'configuration': configuration}
180         cmdclass['build_ext'] = ConditionalOpenMP
181     except ImportError:
182         if len(sys.argv) >= 2 and ('--help' in sys.argv[1:] or
183                                    sys.argv[1] in ('--help-commands',
184                                                    '--version',
185                                                    'clean',
186                                                    'egg_info',
187                                                    'install_egg_info',
188                                                    'rotate',
189                                                    'sdist')):
190             # For these actions, compilation is not required.
191             #
192             # They are required to succeed for example when pip is
193             # used to install scikit-image when Numpy/cython are not
194             # yet present in the system.
195             from setuptools import setup
196             extra = {}
197         else:
198             print(textwrap.dedent("""
199                 To install scikit-image from source, you will need NumPy
200                 and Cython.
201                 Install NumPy, Cython with your python package manager.
202                 If you are using pip, the commands are:
203 
204                   pip install numpy cython pythran
205 
206                 For more details, see:
207 
208                    https://scikit-image.org/docs/stable/install.html
209             """))
210             sys.exit(1)
211 
212     setup(
213         name=DISTNAME,
214         description=DESCRIPTION,
215         long_description=LONG_DESCRIPTION,
216         long_description_content_type="text/markdown",
217         maintainer=MAINTAINER,
218         maintainer_email=MAINTAINER_EMAIL,
219         url=URL,
220         license=LICENSE,
221         download_url=DOWNLOAD_URL,
222         project_urls=PROJECT_URLS,
223         version=VERSION,
224         classifiers=[
225             'Development Status :: 4 - Beta',
226             'Environment :: Console',
227             'Intended Audience :: Developers',
228             'Intended Audience :: Science/Research',
229             'License :: OSI Approved :: BSD License',
230             'Programming Language :: C',
231             'Programming Language :: Python',
232             'Programming Language :: Python :: 3',
233             'Programming Language :: Python :: 3.8',
234             'Programming Language :: Python :: 3.9',
235             'Programming Language :: Python :: 3.10',
236             'Programming Language :: Python :: 3 :: Only',
237             'Topic :: Scientific/Engineering',
238             'Operating System :: Microsoft :: Windows',
239             'Operating System :: POSIX',
240             'Operating System :: Unix',
241             'Operating System :: MacOS',
242         ],
243         install_requires=INSTALL_REQUIRES,
244         extras_require=extras_require,
245         python_requires='>=3.8',
246         packages=setuptools.find_packages(exclude=['doc', 'benchmarks']),
247         include_package_data=True,
248         zip_safe=False,  # the package can run out of an .egg file
249         entry_points={
250             'console_scripts': ['skivi = skimage.scripts.skivi:main'],
251         },
252         cmdclass=cmdclass,
253         **extra
254     )
255
```

Path: `skimage/_build.py`
Content:
```
1 import sys
2 import os
3 from packaging import version
4 from multiprocessing import cpu_count
5 
6 CYTHON_VERSION = '0.23.4'
7 
8 # WindowsError is not defined on unix systems
9 try:
10     WindowsError
11 except NameError:
12     class WindowsError(Exception):
13         pass
14 
15 
16 def _compiled_filename(f):
17     """Check for the presence of a .pyx[.in] file as a .c or .cpp."""
18     basename = f.replace('.in', '').replace('.pyx', '')
19     for ext in ('.c', '.cpp'):
20         filename = basename + ext
21         if os.path.exists(filename):
22             return filename
23     else:
24         raise RuntimeError('Cython >= %s is required to build '
25                            'scikit-image from git checkout' %
26                            CYTHON_VERSION)
27 
28 
29 def cython(pyx_files, working_path=''):
30     """Use Cython to convert the given files to C.
31 
32     Parameters
33     ----------
34     pyx_files : list of str
35         The input .pyx files.
36 
37     """
38     # Do not build cython files if target is clean
39     if len(sys.argv) >= 2 and sys.argv[1] == 'clean':
40         return
41 
42     try:
43         from Cython import __version__
44         if version.parse(__version__) < version.parse(CYTHON_VERSION):
45             raise RuntimeError('Cython >= %s needed to build scikit-image' % CYTHON_VERSION)
46 
47         from Cython.Build import cythonize
48     except ImportError:
49         # If cython is not found, the build will make use of
50         # the distributed .c or .cpp files if present
51         c_files_used = [_compiled_filename(os.path.join(working_path, f))
52                         for f in pyx_files]
53 
54         print("Cython >= %s not found; falling back to pre-built %s" \
55               % (CYTHON_VERSION, " ".join(c_files_used)))
56     else:
57         pyx_files = [os.path.join(working_path, f) for f in pyx_files]
58         for i, pyxfile in enumerate(pyx_files):
59             if pyxfile.endswith('.pyx.in'):
60                 process_tempita_pyx(pyxfile)
61                 pyx_files[i] = pyxfile.replace('.pyx.in', '.pyx')
62 
63         # Cython doesn't automatically choose a number of threads > 1
64         # https://github.com/cython/cython/blob/a0bbb940c847dfe92cac446c8784c34c28c92836/Cython/Build/Dependencies.py#L923-L925
65         cythonize(pyx_files, nthreads=cpu_count(),
66                   compiler_directives={'language_level': 3})
67 
68 
69 def process_tempita_pyx(fromfile):
70     try:
71         try:
72             from Cython import Tempita as tempita
73         except ImportError:
74             import tempita
75     except ImportError:
76         raise Exception('Building requires Tempita: '
77                         'pip install --user Tempita')
78     template = tempita.Template.from_filename(fromfile,
79                                               encoding=sys.getdefaultencoding())
80     pyxcontent = template.substitute()
81     if not fromfile.endswith('.pyx.in'):
82         raise ValueError("Unexpected extension of %s." % fromfile)
83 
84     pyxfile = os.path.splitext(fromfile)[0]    # split off the .in ending
85     with open(pyxfile, "w") as f:
86         f.write(pyxcontent)
87
```
--- 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
@@ -116,6 +116,8 @@
         else:
             compile_flags += ['-fopenmp']
             link_flags += ['-fopenmp']
+        if 'SKIMAGE_LINK_FLAGS' in os.environ:
+            link_flags += [os.environ['SKIMAGE_LINK_FLAGS']]
 
         if self.can_compile_link(compile_flags, link_flags):
             for ext in self.extensions:
@@ -244,7 +246,7 @@
         extras_require=extras_require,
         python_requires='>=3.8',
         packages=setuptools.find_packages(exclude=['doc', 'benchmarks']),
-        include_package_data=True,
+        include_package_data=False,
         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/_build.py b/skimage/_build.py
--- a/skimage/_build.py
+++ b/skimage/_build.py
@@ -60,10 +60,13 @@
                 process_tempita_pyx(pyxfile)
                 pyx_files[i] = pyxfile.replace('.pyx.in', '.pyx')
 
-        # Cython doesn't automatically choose a number of threads > 1
-        # https://github.com/cython/cython/blob/a0bbb940c847dfe92cac446c8784c34c28c92836/Cython/Build/Dependencies.py#L923-L925
-        cythonize(pyx_files, nthreads=cpu_count(),
-                  compiler_directives={'language_level': 3})
+        # skip cythonize when creating an sdist
+        # (we do not want the large cython-generated sources to be included)
+        if 'sdist' not in sys.argv:
+            # Cython doesn't automatically choose a number of threads > 1
+            # https://github.com/cython/cython/blob/a0bbb940c847dfe92cac446c8784c34c28c92836/Cython/Build/Dependencies.py#L923-L925
+            cythonize(pyx_files, nthreads=cpu_count(),
+                      compiler_directives={'language_level': 3})
 
 
 def process_tempita_pyx(fromfile):

{"golden_diff": "diff --git a/setup.py b/setup.py\n--- a/setup.py\n+++ b/setup.py\n@@ -116,6 +116,8 @@\n         else:\n             compile_flags += ['-fopenmp']\n             link_flags += ['-fopenmp']\n+        if 'SKIMAGE_LINK_FLAGS' in os.environ:\n+            link_flags += [os.environ['SKIMAGE_LINK_FLAGS']]\n \n         if self.can_compile_link(compile_flags, link_flags):\n             for ext in self.extensions:\n@@ -244,7 +246,7 @@\n         extras_require=extras_require,\n         python_requires='>=3.8',\n         packages=setuptools.find_packages(exclude=['doc', 'benchmarks']),\n-        include_package_data=True,\n+        include_package_data=False,\n         zip_safe=False,  # the package can run out of an .egg file\n         entry_points={\n             'console_scripts': ['skivi = skimage.scripts.skivi:main'],\ndiff --git a/skimage/_build.py b/skimage/_build.py\n--- a/skimage/_build.py\n+++ b/skimage/_build.py\n@@ -60,10 +60,13 @@\n                 process_tempita_pyx(pyxfile)\n                 pyx_files[i] = pyxfile.replace('.pyx.in', '.pyx')\n \n-        # Cython doesn't automatically choose a number of threads > 1\n-        # https://github.com/cython/cython/blob/a0bbb940c847dfe92cac446c8784c34c28c92836/Cython/Build/Dependencies.py#L923-L925\n-        cythonize(pyx_files, nthreads=cpu_count(),\n-                  compiler_directives={'language_level': 3})\n+        # skip cythonize when creating an sdist\n+        # (we do not want the large cython-generated sources to be included)\n+        if 'sdist' not in sys.argv:\n+            # Cython doesn't automatically choose a number of threads > 1\n+            # https://github.com/cython/cython/blob/a0bbb940c847dfe92cac446c8784c34c28c92836/Cython/Build/Dependencies.py#L923-L925\n+            cythonize(pyx_files, nthreads=cpu_count(),\n+                      compiler_directives={'language_level': 3})\n \n \n def process_tempita_pyx(fromfile):\n", "issue": "Reduce the wheel size relative to 0.19.0 for upcoming releases\n## Description\r\n\r\nContinuing the discussion from https://github.com/scikit-image/scikit-image/issues/6086#issuecomment-986063471\r\n\r\nWe have seen a recent increase in wheel size by nearly a factor of two for 0.19.0 vs. 0.18.3. In order to be a good citizen, preserving PyPI and CI resources we should try to reduce this if possible.\r\n\r\nSo far, one difference I noticed was that the 0.19.0 wheels have various `.c`, `.cpp` and `.pyx` files that should not need to be in the wheel. \r\n\r\n\n", "before_files": [{"content": "#! /usr/bin/env python\n\nimport os\nimport sys\nimport tempfile\nimport shutil\nimport builtins\nimport textwrap\nfrom numpy.distutils.command.build_ext import build_ext as npy_build_ext\n\nimport setuptools\nfrom setuptools.command.build_py import build_py\nfrom setuptools.command.sdist import sdist\ntry:\n    from setuptools.errors import CompileError, LinkError\nexcept ImportError:\n    # can remove this except case once we require setuptools>=59.0\n    from distutils.errors import CompileError, LinkError\n\nfrom pythran.dist import PythranBuildExt as pythran_build_ext\n\nDISTNAME = 'scikit-image'\nDESCRIPTION = 'Image processing in Python'\nMAINTAINER = 'Stefan van der Walt'\nMAINTAINER_EMAIL = 'stefan@sun.ac.za'\nURL = 'https://scikit-image.org'\nLICENSE = 'Modified BSD'\nDOWNLOAD_URL = 'https://scikit-image.org/docs/stable/install.html'\nPROJECT_URLS = {\n    \"Bug Tracker\": 'https://github.com/scikit-image/scikit-image/issues',\n    \"Documentation\": 'https://scikit-image.org/docs/stable/',\n    \"Source Code\": 'https://github.com/scikit-image/scikit-image'\n}\n\nwith open('README.md', encoding='utf-8') as f:\n    LONG_DESCRIPTION = f.read()\n\nif sys.version_info < (3, 8):\n\n    error = \"\"\"Python {py} detected.\n\nscikit-image supports only Python 3.8 and above.\n\nFor Python 2.7, please install the 0.14.x Long Term Support release using:\n\n $ pip install 'scikit-image<0.15'\n\"\"\".format(py='.'.join([str(v) for v in sys.version_info[:3]]))\n\n    sys.stderr.write(error + \"\\n\")\n    sys.exit(1)\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\n# Support for openmp\n\nclass ConditionalOpenMP(pythran_build_ext[npy_build_ext]):\n\n    def can_compile_link(self, compile_flags, link_flags):\n\n        if \"PYODIDE_PACKAGE_ABI\" in os.environ:\n            # pyodide doesn't support OpenMP\n            return False\n\n        cc = self.compiler\n        fname = 'test.c'\n        cwd = os.getcwd()\n        tmpdir = tempfile.mkdtemp()\n\n        code = (\"#include <omp.h>\"\n                \"int main(int argc, char** argv) { return(0); }\")\n\n        if self.compiler.compiler_type == \"msvc\":\n            # make sure we build a DLL on Windows\n            local_link_flags = link_flags + [\"/DLL\"]\n        else:\n            local_link_flags = link_flags\n\n        try:\n            os.chdir(tmpdir)\n            with open(fname, 'wt') as fobj:\n                fobj.write(code)\n            try:\n                objects = cc.compile([fname],\n                                     extra_postargs=compile_flags)\n            except CompileError:\n                return False\n            try:\n                # Link shared lib rather then executable to avoid\n                # http://bugs.python.org/issue4431 with MSVC 10+\n                cc.link_shared_lib(objects, \"testlib\",\n                                   extra_postargs=local_link_flags)\n            except (LinkError, TypeError):\n                return False\n        finally:\n            os.chdir(cwd)\n            shutil.rmtree(tmpdir)\n        return True\n\n    def build_extensions(self):\n        \"\"\" Hook into extension building to set compiler flags \"\"\"\n\n        compile_flags = list()\n        link_flags = list()\n\n        # check which compiler is being used\n        if self.compiler.compiler_type == \"msvc\":\n            # '-fopenmp' is called '/openmp' in msvc\n            compile_flags += ['/openmp']\n        else:\n            compile_flags += ['-fopenmp']\n            link_flags += ['-fopenmp']\n\n        if self.can_compile_link(compile_flags, link_flags):\n            for ext in self.extensions:\n                ext.extra_compile_args += compile_flags\n                ext.extra_link_args += link_flags\n\n        super(ConditionalOpenMP, self).build_extensions()\n\n\nwith open('skimage/__init__.py', encoding='utf-8') as fid:\n    for line in fid:\n        if line.startswith('__version__'):\n            VERSION = line.strip().split()[-1][1:-1]\n            break\n\n\ndef parse_requirements_file(filename):\n    with open(filename, encoding='utf-8') as fid:\n        requires = [line.strip() for line in fid.readlines() if line]\n\n    return requires\n\n\nINSTALL_REQUIRES = parse_requirements_file('requirements/default.txt')\n# The `requirements/extras.txt` file is explicitely omitted because\n# it contains requirements that do not have wheels uploaded to pip\n# for the platforms we wish to support.\nextras_require = {\n    dep: parse_requirements_file('requirements/' + dep + '.txt')\n    for dep in ['docs', 'optional', 'test', 'data']\n}\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\n    return config\n\n\nif __name__ == \"__main__\":\n    cmdclass = {'build_py': build_py,\n                'sdist': sdist}\n    try:\n        # test if build dependencies exist.\n        # if not, some commands are still viable.\n        # note: this must be kept in sync with pyproject.toml\n        from numpy.distutils.core import setup\n        import cython\n        extra = {'configuration': configuration}\n        cmdclass['build_ext'] = ConditionalOpenMP\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                                                   'sdist')):\n            # For these actions, compilation is not required.\n            #\n            # They are required to succeed for example when pip is\n            # used to install scikit-image when Numpy/cython are not\n            # yet present in the system.\n            from setuptools import setup\n            extra = {}\n        else:\n            print(textwrap.dedent(\"\"\"\n                To install scikit-image from source, you will need NumPy\n                and Cython.\n                Install NumPy, Cython with your python package manager.\n                If you are using pip, the commands are:\n\n                  pip install numpy cython pythran\n\n                For more details, see:\n\n                   https://scikit-image.org/docs/stable/install.html\n            \"\"\"))\n            sys.exit(1)\n\n    setup(\n        name=DISTNAME,\n        description=DESCRIPTION,\n        long_description=LONG_DESCRIPTION,\n        long_description_content_type=\"text/markdown\",\n        maintainer=MAINTAINER,\n        maintainer_email=MAINTAINER_EMAIL,\n        url=URL,\n        license=LICENSE,\n        download_url=DOWNLOAD_URL,\n        project_urls=PROJECT_URLS,\n        version=VERSION,\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            'Programming Language :: Python :: 3.8',\n            'Programming Language :: Python :: 3.9',\n            'Programming Language :: Python :: 3.10',\n            'Programming Language :: Python :: 3 :: Only',\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        extras_require=extras_require,\n        python_requires='>=3.8',\n        packages=setuptools.find_packages(exclude=['doc', 'benchmarks']),\n        include_package_data=True,\n        zip_safe=False,  # the package can run out of an .egg file\n        entry_points={\n            'console_scripts': ['skivi = skimage.scripts.skivi:main'],\n        },\n        cmdclass=cmdclass,\n        **extra\n    )\n", "path": "setup.py"}, {"content": "import sys\nimport os\nfrom packaging import version\nfrom multiprocessing import cpu_count\n\nCYTHON_VERSION = '0.23.4'\n\n# WindowsError is not defined on unix systems\ntry:\n    WindowsError\nexcept NameError:\n    class WindowsError(Exception):\n        pass\n\n\ndef _compiled_filename(f):\n    \"\"\"Check for the presence of a .pyx[.in] file as a .c or .cpp.\"\"\"\n    basename = f.replace('.in', '').replace('.pyx', '')\n    for ext in ('.c', '.cpp'):\n        filename = basename + ext\n        if os.path.exists(filename):\n            return filename\n    else:\n        raise RuntimeError('Cython >= %s is required to build '\n                           'scikit-image from git checkout' %\n                           CYTHON_VERSION)\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 version.parse(__version__) < version.parse(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 or .cpp files if present\n        c_files_used = [_compiled_filename(os.path.join(working_path, f))\n                        for f in pyx_files]\n\n        print(\"Cython >= %s not found; falling back to pre-built %s\" \\\n              % (CYTHON_VERSION, \" \".join(c_files_used)))\n    else:\n        pyx_files = [os.path.join(working_path, f) for f in pyx_files]\n        for i, pyxfile in enumerate(pyx_files):\n            if pyxfile.endswith('.pyx.in'):\n                process_tempita_pyx(pyxfile)\n                pyx_files[i] = pyxfile.replace('.pyx.in', '.pyx')\n\n        # Cython doesn't automatically choose a number of threads > 1\n        # https://github.com/cython/cython/blob/a0bbb940c847dfe92cac446c8784c34c28c92836/Cython/Build/Dependencies.py#L923-L925\n        cythonize(pyx_files, nthreads=cpu_count(),\n                  compiler_directives={'language_level': 3})\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\nimport os\nimport sys\nimport tempfile\nimport shutil\nimport builtins\nimport textwrap\nfrom numpy.distutils.command.build_ext import build_ext as npy_build_ext\n\nimport setuptools\nfrom setuptools.command.build_py import build_py\nfrom setuptools.command.sdist import sdist\ntry:\n    from setuptools.errors import CompileError, LinkError\nexcept ImportError:\n    # can remove this except case once we require setuptools>=59.0\n    from distutils.errors import CompileError, LinkError\n\nfrom pythran.dist import PythranBuildExt as pythran_build_ext\n\nDISTNAME = 'scikit-image'\nDESCRIPTION = 'Image processing in Python'\nMAINTAINER = 'Stefan van der Walt'\nMAINTAINER_EMAIL = 'stefan@sun.ac.za'\nURL = 'https://scikit-image.org'\nLICENSE = 'Modified BSD'\nDOWNLOAD_URL = 'https://scikit-image.org/docs/stable/install.html'\nPROJECT_URLS = {\n    \"Bug Tracker\": 'https://github.com/scikit-image/scikit-image/issues',\n    \"Documentation\": 'https://scikit-image.org/docs/stable/',\n    \"Source Code\": 'https://github.com/scikit-image/scikit-image'\n}\n\nwith open('README.md', encoding='utf-8') as f:\n    LONG_DESCRIPTION = f.read()\n\nif sys.version_info < (3, 8):\n\n    error = \"\"\"Python {py} detected.\n\nscikit-image supports only Python 3.8 and above.\n\nFor Python 2.7, please install the 0.14.x Long Term Support release using:\n\n $ pip install 'scikit-image<0.15'\n\"\"\".format(py='.'.join([str(v) for v in sys.version_info[:3]]))\n\n    sys.stderr.write(error + \"\\n\")\n    sys.exit(1)\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\n# Support for openmp\n\nclass ConditionalOpenMP(pythran_build_ext[npy_build_ext]):\n\n    def can_compile_link(self, compile_flags, link_flags):\n\n        if \"PYODIDE_PACKAGE_ABI\" in os.environ:\n            # pyodide doesn't support OpenMP\n            return False\n\n        cc = self.compiler\n        fname = 'test.c'\n        cwd = os.getcwd()\n        tmpdir = tempfile.mkdtemp()\n\n        code = (\"#include <omp.h>\"\n                \"int main(int argc, char** argv) { return(0); }\")\n\n        if self.compiler.compiler_type == \"msvc\":\n            # make sure we build a DLL on Windows\n            local_link_flags = link_flags + [\"/DLL\"]\n        else:\n            local_link_flags = link_flags\n\n        try:\n            os.chdir(tmpdir)\n            with open(fname, 'wt') as fobj:\n                fobj.write(code)\n            try:\n                objects = cc.compile([fname],\n                                     extra_postargs=compile_flags)\n            except CompileError:\n                return False\n            try:\n                # Link shared lib rather then executable to avoid\n                # http://bugs.python.org/issue4431 with MSVC 10+\n                cc.link_shared_lib(objects, \"testlib\",\n                                   extra_postargs=local_link_flags)\n            except (LinkError, TypeError):\n                return False\n        finally:\n            os.chdir(cwd)\n            shutil.rmtree(tmpdir)\n        return True\n\n    def build_extensions(self):\n        \"\"\" Hook into extension building to set compiler flags \"\"\"\n\n        compile_flags = list()\n        link_flags = list()\n\n        # check which compiler is being used\n        if self.compiler.compiler_type == \"msvc\":\n            # '-fopenmp' is called '/openmp' in msvc\n            compile_flags += ['/openmp']\n        else:\n            compile_flags += ['-fopenmp']\n            link_flags += ['-fopenmp']\n        if 'SKIMAGE_LINK_FLAGS' in os.environ:\n            link_flags += [os.environ['SKIMAGE_LINK_FLAGS']]\n\n        if self.can_compile_link(compile_flags, link_flags):\n            for ext in self.extensions:\n                ext.extra_compile_args += compile_flags\n                ext.extra_link_args += link_flags\n\n        super(ConditionalOpenMP, self).build_extensions()\n\n\nwith open('skimage/__init__.py', encoding='utf-8') as fid:\n    for line in fid:\n        if line.startswith('__version__'):\n            VERSION = line.strip().split()[-1][1:-1]\n            break\n\n\ndef parse_requirements_file(filename):\n    with open(filename, encoding='utf-8') as fid:\n        requires = [line.strip() for line in fid.readlines() if line]\n\n    return requires\n\n\nINSTALL_REQUIRES = parse_requirements_file('requirements/default.txt')\n# The `requirements/extras.txt` file is explicitely omitted because\n# it contains requirements that do not have wheels uploaded to pip\n# for the platforms we wish to support.\nextras_require = {\n    dep: parse_requirements_file('requirements/' + dep + '.txt')\n    for dep in ['docs', 'optional', 'test', 'data']\n}\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\n    return config\n\n\nif __name__ == \"__main__\":\n    cmdclass = {'build_py': build_py,\n                'sdist': sdist}\n    try:\n        # test if build dependencies exist.\n        # if not, some commands are still viable.\n        # note: this must be kept in sync with pyproject.toml\n        from numpy.distutils.core import setup\n        import cython\n        extra = {'configuration': configuration}\n        cmdclass['build_ext'] = ConditionalOpenMP\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                                                   'sdist')):\n            # For these actions, compilation is not required.\n            #\n            # They are required to succeed for example when pip is\n            # used to install scikit-image when Numpy/cython are not\n            # yet present in the system.\n            from setuptools import setup\n            extra = {}\n        else:\n            print(textwrap.dedent(\"\"\"\n                To install scikit-image from source, you will need NumPy\n                and Cython.\n                Install NumPy, Cython with your python package manager.\n                If you are using pip, the commands are:\n\n                  pip install numpy cython pythran\n\n                For more details, see:\n\n                   https://scikit-image.org/docs/stable/install.html\n            \"\"\"))\n            sys.exit(1)\n\n    setup(\n        name=DISTNAME,\n        description=DESCRIPTION,\n        long_description=LONG_DESCRIPTION,\n        long_description_content_type=\"text/markdown\",\n        maintainer=MAINTAINER,\n        maintainer_email=MAINTAINER_EMAIL,\n        url=URL,\n        license=LICENSE,\n        download_url=DOWNLOAD_URL,\n        project_urls=PROJECT_URLS,\n        version=VERSION,\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            'Programming Language :: Python :: 3.8',\n            'Programming Language :: Python :: 3.9',\n            'Programming Language :: Python :: 3.10',\n            'Programming Language :: Python :: 3 :: Only',\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        extras_require=extras_require,\n        python_requires='>=3.8',\n        packages=setuptools.find_packages(exclude=['doc', 'benchmarks']),\n        include_package_data=False,\n        zip_safe=False,  # the package can run out of an .egg file\n        entry_points={\n            'console_scripts': ['skivi = skimage.scripts.skivi:main'],\n        },\n        cmdclass=cmdclass,\n        **extra\n    )\n", "path": "setup.py"}, {"content": "import sys\nimport os\nfrom packaging import version\nfrom multiprocessing import cpu_count\n\nCYTHON_VERSION = '0.23.4'\n\n# WindowsError is not defined on unix systems\ntry:\n    WindowsError\nexcept NameError:\n    class WindowsError(Exception):\n        pass\n\n\ndef _compiled_filename(f):\n    \"\"\"Check for the presence of a .pyx[.in] file as a .c or .cpp.\"\"\"\n    basename = f.replace('.in', '').replace('.pyx', '')\n    for ext in ('.c', '.cpp'):\n        filename = basename + ext\n        if os.path.exists(filename):\n            return filename\n    else:\n        raise RuntimeError('Cython >= %s is required to build '\n                           'scikit-image from git checkout' %\n                           CYTHON_VERSION)\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 version.parse(__version__) < version.parse(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 or .cpp files if present\n        c_files_used = [_compiled_filename(os.path.join(working_path, f))\n                        for f in pyx_files]\n\n        print(\"Cython >= %s not found; falling back to pre-built %s\" \\\n              % (CYTHON_VERSION, \" \".join(c_files_used)))\n    else:\n        pyx_files = [os.path.join(working_path, f) for f in pyx_files]\n        for i, pyxfile in enumerate(pyx_files):\n            if pyxfile.endswith('.pyx.in'):\n                process_tempita_pyx(pyxfile)\n                pyx_files[i] = pyxfile.replace('.pyx.in', '.pyx')\n\n        # skip cythonize when creating an sdist\n        # (we do not want the large cython-generated sources to be included)\n        if 'sdist' not in sys.argv:\n            # Cython doesn't automatically choose a number of threads > 1\n            # https://github.com/cython/cython/blob/a0bbb940c847dfe92cac446c8784c34c28c92836/Cython/Build/Dependencies.py#L923-L925\n            cythonize(pyx_files, nthreads=cpu_count(),\n                      compiler_directives={'language_level': 3})\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"}]}