We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Deprecate setuptools.installer but not setup_requires
> You're going to break entire workflows and distros with this, please reconsider.

I'm tempted to un-deprecate `setup_requires` as a parameter, but to deprecate/remove only the `fetch_build_eggs` part. In other words, continue to allow `setup_requires` to supply requirements for PEP 517 hooks (`get_requires_for_build_sdist` and `get_requires_for_build_wheel`).


_Originally posted by @jaraco in https://github.com/pypa/setuptools/issues/2824#issuecomment-967430754_

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `setuptools/installer.py`
Content:
```
1 import glob
2 import os
3 import subprocess
4 import sys
5 import tempfile
6 from distutils import log
7 from distutils.errors import DistutilsError
8 
9 import pkg_resources
10 from setuptools.wheel import Wheel
11 
12 
13 def _fixup_find_links(find_links):
14     """Ensure find-links option end-up being a list of strings."""
15     if isinstance(find_links, str):
16         return find_links.split()
17     assert isinstance(find_links, (tuple, list))
18     return find_links
19 
20 
21 def fetch_build_egg(dist, req):  # noqa: C901  # is too complex (16)  # FIXME
22     """Fetch an egg needed for building.
23 
24     Use pip/wheel to fetch/build a wheel."""
25     # Warn if wheel is not available
26     try:
27         pkg_resources.get_distribution('wheel')
28     except pkg_resources.DistributionNotFound:
29         dist.announce('WARNING: The wheel package is not available.', log.WARN)
30     # Ignore environment markers; if supplied, it is required.
31     req = strip_marker(req)
32     # Take easy_install options into account, but do not override relevant
33     # pip environment variables (like PIP_INDEX_URL or PIP_QUIET); they'll
34     # take precedence.
35     opts = dist.get_option_dict('easy_install')
36     if 'allow_hosts' in opts:
37         raise DistutilsError('the `allow-hosts` option is not supported '
38                              'when using pip to install requirements.')
39     quiet = 'PIP_QUIET' not in os.environ and 'PIP_VERBOSE' not in os.environ
40     if 'PIP_INDEX_URL' in os.environ:
41         index_url = None
42     elif 'index_url' in opts:
43         index_url = opts['index_url'][1]
44     else:
45         index_url = None
46     find_links = (
47         _fixup_find_links(opts['find_links'][1])[:] if 'find_links' in opts
48         else []
49     )
50     if dist.dependency_links:
51         find_links.extend(dist.dependency_links)
52     eggs_dir = os.path.realpath(dist.get_egg_cache_dir())
53     environment = pkg_resources.Environment()
54     for egg_dist in pkg_resources.find_distributions(eggs_dir):
55         if egg_dist in req and environment.can_add(egg_dist):
56             return egg_dist
57     with tempfile.TemporaryDirectory() as tmpdir:
58         cmd = [
59             sys.executable, '-m', 'pip',
60             '--disable-pip-version-check',
61             'wheel', '--no-deps',
62             '-w', tmpdir,
63         ]
64         if quiet:
65             cmd.append('--quiet')
66         if index_url is not None:
67             cmd.extend(('--index-url', index_url))
68         for link in find_links or []:
69             cmd.extend(('--find-links', link))
70         # If requirement is a PEP 508 direct URL, directly pass
71         # the URL to pip, as `req @ url` does not work on the
72         # command line.
73         cmd.append(req.url or str(req))
74         try:
75             subprocess.check_call(cmd)
76         except subprocess.CalledProcessError as e:
77             raise DistutilsError(str(e)) from e
78         wheel = Wheel(glob.glob(os.path.join(tmpdir, '*.whl'))[0])
79         dist_location = os.path.join(eggs_dir, wheel.egg_name())
80         wheel.install_as_egg(dist_location)
81         dist_metadata = pkg_resources.PathMetadata(
82             dist_location, os.path.join(dist_location, 'EGG-INFO'))
83         dist = pkg_resources.Distribution.from_filename(
84             dist_location, metadata=dist_metadata)
85         return dist
86 
87 
88 def strip_marker(req):
89     """
90     Return a new requirement without the environment marker to avoid
91     calling pip with something like `babel; extra == "i18n"`, which
92     would always be ignored.
93     """
94     # create a copy to avoid mutating the input
95     req = pkg_resources.Requirement.parse(str(req))
96     req.marker = None
97     return req
98
```

Path: `setuptools/__init__.py`
Content:
```
1 """Extensions to the 'distutils' for large or complex distributions"""
2 
3 from fnmatch import fnmatchcase
4 import functools
5 import os
6 import re
7 import warnings
8 
9 import _distutils_hack.override  # noqa: F401
10 
11 import distutils.core
12 from distutils.errors import DistutilsOptionError
13 from distutils.util import convert_path
14 
15 from ._deprecation_warning import SetuptoolsDeprecationWarning
16 
17 import setuptools.version
18 from setuptools.extension import Extension
19 from setuptools.dist import Distribution
20 from setuptools.depends import Require
21 from . import monkey
22 
23 
24 __all__ = [
25     'setup',
26     'Distribution',
27     'Command',
28     'Extension',
29     'Require',
30     'SetuptoolsDeprecationWarning',
31     'find_packages',
32     'find_namespace_packages',
33 ]
34 
35 __version__ = setuptools.version.__version__
36 
37 bootstrap_install_from = None
38 
39 
40 class PackageFinder:
41     """
42     Generate a list of all Python packages found within a directory
43     """
44 
45     @classmethod
46     def find(cls, where='.', exclude=(), include=('*',)):
47         """Return a list all Python packages found within directory 'where'
48 
49         'where' is the root directory which will be searched for packages.  It
50         should be supplied as a "cross-platform" (i.e. URL-style) path; it will
51         be converted to the appropriate local path syntax.
52 
53         'exclude' is a sequence of package names to exclude; '*' can be used
54         as a wildcard in the names, such that 'foo.*' will exclude all
55         subpackages of 'foo' (but not 'foo' itself).
56 
57         'include' is a sequence of package names to include.  If it's
58         specified, only the named packages will be included.  If it's not
59         specified, all found packages will be included.  'include' can contain
60         shell style wildcard patterns just like 'exclude'.
61         """
62 
63         return list(
64             cls._find_packages_iter(
65                 convert_path(where),
66                 cls._build_filter('ez_setup', '*__pycache__', *exclude),
67                 cls._build_filter(*include),
68             )
69         )
70 
71     @classmethod
72     def _find_packages_iter(cls, where, exclude, include):
73         """
74         All the packages found in 'where' that pass the 'include' filter, but
75         not the 'exclude' filter.
76         """
77         for root, dirs, files in os.walk(where, followlinks=True):
78             # Copy dirs to iterate over it, then empty dirs.
79             all_dirs = dirs[:]
80             dirs[:] = []
81 
82             for dir in all_dirs:
83                 full_path = os.path.join(root, dir)
84                 rel_path = os.path.relpath(full_path, where)
85                 package = rel_path.replace(os.path.sep, '.')
86 
87                 # Skip directory trees that are not valid packages
88                 if '.' in dir or not cls._looks_like_package(full_path):
89                     continue
90 
91                 # Should this package be included?
92                 if include(package) and not exclude(package):
93                     yield package
94 
95                 # Keep searching subdirectories, as there may be more packages
96                 # down there, even if the parent was excluded.
97                 dirs.append(dir)
98 
99     @staticmethod
100     def _looks_like_package(path):
101         """Does a directory look like a package?"""
102         return os.path.isfile(os.path.join(path, '__init__.py'))
103 
104     @staticmethod
105     def _build_filter(*patterns):
106         """
107         Given a list of patterns, return a callable that will be true only if
108         the input matches at least one of the patterns.
109         """
110         return lambda name: any(fnmatchcase(name, pat=pat) for pat in patterns)
111 
112 
113 class PEP420PackageFinder(PackageFinder):
114     @staticmethod
115     def _looks_like_package(path):
116         return True
117 
118 
119 find_packages = PackageFinder.find
120 find_namespace_packages = PEP420PackageFinder.find
121 
122 
123 def _install_setup_requires(attrs):
124     # Note: do not use `setuptools.Distribution` directly, as
125     # our PEP 517 backend patch `distutils.core.Distribution`.
126     class MinimalDistribution(distutils.core.Distribution):
127         """
128         A minimal version of a distribution for supporting the
129         fetch_build_eggs interface.
130         """
131 
132         def __init__(self, attrs):
133             _incl = 'dependency_links', 'setup_requires'
134             filtered = {k: attrs[k] for k in set(_incl) & set(attrs)}
135             distutils.core.Distribution.__init__(self, filtered)
136 
137         def finalize_options(self):
138             """
139             Disable finalize_options to avoid building the working set.
140             Ref #2158.
141             """
142 
143     dist = MinimalDistribution(attrs)
144 
145     # Honor setup.cfg's options.
146     dist.parse_config_files(ignore_option_errors=True)
147     if dist.setup_requires:
148         warnings.warn(
149             "setup_requires is deprecated. Supply build "
150             "dependencies using PEP 517 pyproject.toml build-requires.",
151             SetuptoolsDeprecationWarning,
152         )
153         dist.fetch_build_eggs(dist.setup_requires)
154 
155 
156 def setup(**attrs):
157     # Make sure we have any requirements needed to interpret 'attrs'.
158     _install_setup_requires(attrs)
159     return distutils.core.setup(**attrs)
160 
161 
162 setup.__doc__ = distutils.core.setup.__doc__
163 
164 
165 _Command = monkey.get_unpatched(distutils.core.Command)
166 
167 
168 class Command(_Command):
169     __doc__ = _Command.__doc__
170 
171     command_consumes_arguments = False
172 
173     def __init__(self, dist, **kw):
174         """
175         Construct the command for dist, updating
176         vars(self) with any keyword parameters.
177         """
178         _Command.__init__(self, dist)
179         vars(self).update(kw)
180 
181     def _ensure_stringlike(self, option, what, default=None):
182         val = getattr(self, option)
183         if val is None:
184             setattr(self, option, default)
185             return default
186         elif not isinstance(val, str):
187             raise DistutilsOptionError(
188                 "'%s' must be a %s (got `%s`)" % (option, what, val)
189             )
190         return val
191 
192     def ensure_string_list(self, option):
193         r"""Ensure that 'option' is a list of strings.  If 'option' is
194         currently a string, we split it either on /,\s*/ or /\s+/, so
195         "foo bar baz", "foo,bar,baz", and "foo,   bar baz" all become
196         ["foo", "bar", "baz"].
197         """
198         val = getattr(self, option)
199         if val is None:
200             return
201         elif isinstance(val, str):
202             setattr(self, option, re.split(r',\s*|\s+', val))
203         else:
204             if isinstance(val, list):
205                 ok = all(isinstance(v, str) for v in val)
206             else:
207                 ok = False
208             if not ok:
209                 raise DistutilsOptionError(
210                     "'%s' must be a list of strings (got %r)" % (option, val)
211                 )
212 
213     def reinitialize_command(self, command, reinit_subcommands=0, **kw):
214         cmd = _Command.reinitialize_command(self, command, reinit_subcommands)
215         vars(cmd).update(kw)
216         return cmd
217 
218 
219 def _find_all_simple(path):
220     """
221     Find all files under 'path'
222     """
223     results = (
224         os.path.join(base, file)
225         for base, dirs, files in os.walk(path, followlinks=True)
226         for file in files
227     )
228     return filter(os.path.isfile, results)
229 
230 
231 def findall(dir=os.curdir):
232     """
233     Find all files under 'dir' and return the list of full filenames.
234     Unless dir is '.', return full filenames with dir prepended.
235     """
236     files = _find_all_simple(dir)
237     if dir == os.curdir:
238         make_rel = functools.partial(os.path.relpath, start=dir)
239         files = map(make_rel, files)
240     return list(files)
241 
242 
243 class sic(str):
244     """Treat this string as-is (https://en.wikipedia.org/wiki/Sic)"""
245 
246 
247 # Apply monkey patches
248 monkey.patch_all()
249
```
--- 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/setuptools/__init__.py b/setuptools/__init__.py
--- a/setuptools/__init__.py
+++ b/setuptools/__init__.py
@@ -4,7 +4,6 @@
 import functools
 import os
 import re
-import warnings
 
 import _distutils_hack.override  # noqa: F401
 
@@ -145,11 +144,6 @@
     # Honor setup.cfg's options.
     dist.parse_config_files(ignore_option_errors=True)
     if dist.setup_requires:
-        warnings.warn(
-            "setup_requires is deprecated. Supply build "
-            "dependencies using PEP 517 pyproject.toml build-requires.",
-            SetuptoolsDeprecationWarning,
-        )
         dist.fetch_build_eggs(dist.setup_requires)
 
 
diff --git a/setuptools/installer.py b/setuptools/installer.py
--- a/setuptools/installer.py
+++ b/setuptools/installer.py
@@ -3,11 +3,13 @@
 import subprocess
 import sys
 import tempfile
+import warnings
 from distutils import log
 from distutils.errors import DistutilsError
 
 import pkg_resources
 from setuptools.wheel import Wheel
+from ._deprecation_warning import SetuptoolsDeprecationWarning
 
 
 def _fixup_find_links(find_links):
@@ -22,6 +24,11 @@
     """Fetch an egg needed for building.
 
     Use pip/wheel to fetch/build a wheel."""
+    warnings.warn(
+        "setuptools.installer is deprecated. Requirements should "
+        "be satisfied by a PEP 517 installer.",
+        SetuptoolsDeprecationWarning,
+    )
     # Warn if wheel is not available
     try:
         pkg_resources.get_distribution('wheel')

{"golden_diff": "diff --git a/setuptools/__init__.py b/setuptools/__init__.py\n--- a/setuptools/__init__.py\n+++ b/setuptools/__init__.py\n@@ -4,7 +4,6 @@\n import functools\n import os\n import re\n-import warnings\n \n import _distutils_hack.override  # noqa: F401\n \n@@ -145,11 +144,6 @@\n     # Honor setup.cfg's options.\n     dist.parse_config_files(ignore_option_errors=True)\n     if dist.setup_requires:\n-        warnings.warn(\n-            \"setup_requires is deprecated. Supply build \"\n-            \"dependencies using PEP 517 pyproject.toml build-requires.\",\n-            SetuptoolsDeprecationWarning,\n-        )\n         dist.fetch_build_eggs(dist.setup_requires)\n \n \ndiff --git a/setuptools/installer.py b/setuptools/installer.py\n--- a/setuptools/installer.py\n+++ b/setuptools/installer.py\n@@ -3,11 +3,13 @@\n import subprocess\n import sys\n import tempfile\n+import warnings\n from distutils import log\n from distutils.errors import DistutilsError\n \n import pkg_resources\n from setuptools.wheel import Wheel\n+from ._deprecation_warning import SetuptoolsDeprecationWarning\n \n \n def _fixup_find_links(find_links):\n@@ -22,6 +24,11 @@\n     \"\"\"Fetch an egg needed for building.\n \n     Use pip/wheel to fetch/build a wheel.\"\"\"\n+    warnings.warn(\n+        \"setuptools.installer is deprecated. Requirements should \"\n+        \"be satisfied by a PEP 517 installer.\",\n+        SetuptoolsDeprecationWarning,\n+    )\n     # Warn if wheel is not available\n     try:\n         pkg_resources.get_distribution('wheel')\n", "issue": "Deprecate setuptools.installer but not setup_requires\n> You're going to break entire workflows and distros with this, please reconsider.\r\n\r\nI'm tempted to un-deprecate `setup_requires` as a parameter, but to deprecate/remove only the `fetch_build_eggs` part. In other words, continue to allow `setup_requires` to supply requirements for PEP 517 hooks (`get_requires_for_build_sdist` and `get_requires_for_build_wheel`).\r\n\r\n\r\n_Originally posted by @jaraco in https://github.com/pypa/setuptools/issues/2824#issuecomment-967430754_\n", "before_files": [{"content": "import glob\nimport os\nimport subprocess\nimport sys\nimport tempfile\nfrom distutils import log\nfrom distutils.errors import DistutilsError\n\nimport pkg_resources\nfrom setuptools.wheel import Wheel\n\n\ndef _fixup_find_links(find_links):\n    \"\"\"Ensure find-links option end-up being a list of strings.\"\"\"\n    if isinstance(find_links, str):\n        return find_links.split()\n    assert isinstance(find_links, (tuple, list))\n    return find_links\n\n\ndef fetch_build_egg(dist, req):  # noqa: C901  # is too complex (16)  # FIXME\n    \"\"\"Fetch an egg needed for building.\n\n    Use pip/wheel to fetch/build a wheel.\"\"\"\n    # Warn if wheel is not available\n    try:\n        pkg_resources.get_distribution('wheel')\n    except pkg_resources.DistributionNotFound:\n        dist.announce('WARNING: The wheel package is not available.', log.WARN)\n    # Ignore environment markers; if supplied, it is required.\n    req = strip_marker(req)\n    # Take easy_install options into account, but do not override relevant\n    # pip environment variables (like PIP_INDEX_URL or PIP_QUIET); they'll\n    # take precedence.\n    opts = dist.get_option_dict('easy_install')\n    if 'allow_hosts' in opts:\n        raise DistutilsError('the `allow-hosts` option is not supported '\n                             'when using pip to install requirements.')\n    quiet = 'PIP_QUIET' not in os.environ and 'PIP_VERBOSE' not in os.environ\n    if 'PIP_INDEX_URL' in os.environ:\n        index_url = None\n    elif 'index_url' in opts:\n        index_url = opts['index_url'][1]\n    else:\n        index_url = None\n    find_links = (\n        _fixup_find_links(opts['find_links'][1])[:] if 'find_links' in opts\n        else []\n    )\n    if dist.dependency_links:\n        find_links.extend(dist.dependency_links)\n    eggs_dir = os.path.realpath(dist.get_egg_cache_dir())\n    environment = pkg_resources.Environment()\n    for egg_dist in pkg_resources.find_distributions(eggs_dir):\n        if egg_dist in req and environment.can_add(egg_dist):\n            return egg_dist\n    with tempfile.TemporaryDirectory() as tmpdir:\n        cmd = [\n            sys.executable, '-m', 'pip',\n            '--disable-pip-version-check',\n            'wheel', '--no-deps',\n            '-w', tmpdir,\n        ]\n        if quiet:\n            cmd.append('--quiet')\n        if index_url is not None:\n            cmd.extend(('--index-url', index_url))\n        for link in find_links or []:\n            cmd.extend(('--find-links', link))\n        # If requirement is a PEP 508 direct URL, directly pass\n        # the URL to pip, as `req @ url` does not work on the\n        # command line.\n        cmd.append(req.url or str(req))\n        try:\n            subprocess.check_call(cmd)\n        except subprocess.CalledProcessError as e:\n            raise DistutilsError(str(e)) from e\n        wheel = Wheel(glob.glob(os.path.join(tmpdir, '*.whl'))[0])\n        dist_location = os.path.join(eggs_dir, wheel.egg_name())\n        wheel.install_as_egg(dist_location)\n        dist_metadata = pkg_resources.PathMetadata(\n            dist_location, os.path.join(dist_location, 'EGG-INFO'))\n        dist = pkg_resources.Distribution.from_filename(\n            dist_location, metadata=dist_metadata)\n        return dist\n\n\ndef strip_marker(req):\n    \"\"\"\n    Return a new requirement without the environment marker to avoid\n    calling pip with something like `babel; extra == \"i18n\"`, which\n    would always be ignored.\n    \"\"\"\n    # create a copy to avoid mutating the input\n    req = pkg_resources.Requirement.parse(str(req))\n    req.marker = None\n    return req\n", "path": "setuptools/installer.py"}, {"content": "\"\"\"Extensions to the 'distutils' for large or complex distributions\"\"\"\n\nfrom fnmatch import fnmatchcase\nimport functools\nimport os\nimport re\nimport warnings\n\nimport _distutils_hack.override  # noqa: F401\n\nimport distutils.core\nfrom distutils.errors import DistutilsOptionError\nfrom distutils.util import convert_path\n\nfrom ._deprecation_warning import SetuptoolsDeprecationWarning\n\nimport setuptools.version\nfrom setuptools.extension import Extension\nfrom setuptools.dist import Distribution\nfrom setuptools.depends import Require\nfrom . import monkey\n\n\n__all__ = [\n    'setup',\n    'Distribution',\n    'Command',\n    'Extension',\n    'Require',\n    'SetuptoolsDeprecationWarning',\n    'find_packages',\n    'find_namespace_packages',\n]\n\n__version__ = setuptools.version.__version__\n\nbootstrap_install_from = None\n\n\nclass PackageFinder:\n    \"\"\"\n    Generate a list of all Python packages found within a directory\n    \"\"\"\n\n    @classmethod\n    def find(cls, where='.', exclude=(), include=('*',)):\n        \"\"\"Return a list all Python packages found within directory 'where'\n\n        'where' is the root directory which will be searched for packages.  It\n        should be supplied as a \"cross-platform\" (i.e. URL-style) path; it will\n        be converted to the appropriate local path syntax.\n\n        'exclude' is a sequence of package names to exclude; '*' can be used\n        as a wildcard in the names, such that 'foo.*' will exclude all\n        subpackages of 'foo' (but not 'foo' itself).\n\n        'include' is a sequence of package names to include.  If it's\n        specified, only the named packages will be included.  If it's not\n        specified, all found packages will be included.  'include' can contain\n        shell style wildcard patterns just like 'exclude'.\n        \"\"\"\n\n        return list(\n            cls._find_packages_iter(\n                convert_path(where),\n                cls._build_filter('ez_setup', '*__pycache__', *exclude),\n                cls._build_filter(*include),\n            )\n        )\n\n    @classmethod\n    def _find_packages_iter(cls, where, exclude, include):\n        \"\"\"\n        All the packages found in 'where' that pass the 'include' filter, but\n        not the 'exclude' filter.\n        \"\"\"\n        for root, dirs, files in os.walk(where, followlinks=True):\n            # Copy dirs to iterate over it, then empty dirs.\n            all_dirs = dirs[:]\n            dirs[:] = []\n\n            for dir in all_dirs:\n                full_path = os.path.join(root, dir)\n                rel_path = os.path.relpath(full_path, where)\n                package = rel_path.replace(os.path.sep, '.')\n\n                # Skip directory trees that are not valid packages\n                if '.' in dir or not cls._looks_like_package(full_path):\n                    continue\n\n                # Should this package be included?\n                if include(package) and not exclude(package):\n                    yield package\n\n                # Keep searching subdirectories, as there may be more packages\n                # down there, even if the parent was excluded.\n                dirs.append(dir)\n\n    @staticmethod\n    def _looks_like_package(path):\n        \"\"\"Does a directory look like a package?\"\"\"\n        return os.path.isfile(os.path.join(path, '__init__.py'))\n\n    @staticmethod\n    def _build_filter(*patterns):\n        \"\"\"\n        Given a list of patterns, return a callable that will be true only if\n        the input matches at least one of the patterns.\n        \"\"\"\n        return lambda name: any(fnmatchcase(name, pat=pat) for pat in patterns)\n\n\nclass PEP420PackageFinder(PackageFinder):\n    @staticmethod\n    def _looks_like_package(path):\n        return True\n\n\nfind_packages = PackageFinder.find\nfind_namespace_packages = PEP420PackageFinder.find\n\n\ndef _install_setup_requires(attrs):\n    # Note: do not use `setuptools.Distribution` directly, as\n    # our PEP 517 backend patch `distutils.core.Distribution`.\n    class MinimalDistribution(distutils.core.Distribution):\n        \"\"\"\n        A minimal version of a distribution for supporting the\n        fetch_build_eggs interface.\n        \"\"\"\n\n        def __init__(self, attrs):\n            _incl = 'dependency_links', 'setup_requires'\n            filtered = {k: attrs[k] for k in set(_incl) & set(attrs)}\n            distutils.core.Distribution.__init__(self, filtered)\n\n        def finalize_options(self):\n            \"\"\"\n            Disable finalize_options to avoid building the working set.\n            Ref #2158.\n            \"\"\"\n\n    dist = MinimalDistribution(attrs)\n\n    # Honor setup.cfg's options.\n    dist.parse_config_files(ignore_option_errors=True)\n    if dist.setup_requires:\n        warnings.warn(\n            \"setup_requires is deprecated. Supply build \"\n            \"dependencies using PEP 517 pyproject.toml build-requires.\",\n            SetuptoolsDeprecationWarning,\n        )\n        dist.fetch_build_eggs(dist.setup_requires)\n\n\ndef setup(**attrs):\n    # Make sure we have any requirements needed to interpret 'attrs'.\n    _install_setup_requires(attrs)\n    return distutils.core.setup(**attrs)\n\n\nsetup.__doc__ = distutils.core.setup.__doc__\n\n\n_Command = monkey.get_unpatched(distutils.core.Command)\n\n\nclass Command(_Command):\n    __doc__ = _Command.__doc__\n\n    command_consumes_arguments = False\n\n    def __init__(self, dist, **kw):\n        \"\"\"\n        Construct the command for dist, updating\n        vars(self) with any keyword parameters.\n        \"\"\"\n        _Command.__init__(self, dist)\n        vars(self).update(kw)\n\n    def _ensure_stringlike(self, option, what, default=None):\n        val = getattr(self, option)\n        if val is None:\n            setattr(self, option, default)\n            return default\n        elif not isinstance(val, str):\n            raise DistutilsOptionError(\n                \"'%s' must be a %s (got `%s`)\" % (option, what, val)\n            )\n        return val\n\n    def ensure_string_list(self, option):\n        r\"\"\"Ensure that 'option' is a list of strings.  If 'option' is\n        currently a string, we split it either on /,\\s*/ or /\\s+/, so\n        \"foo bar baz\", \"foo,bar,baz\", and \"foo,   bar baz\" all become\n        [\"foo\", \"bar\", \"baz\"].\n        \"\"\"\n        val = getattr(self, option)\n        if val is None:\n            return\n        elif isinstance(val, str):\n            setattr(self, option, re.split(r',\\s*|\\s+', val))\n        else:\n            if isinstance(val, list):\n                ok = all(isinstance(v, str) for v in val)\n            else:\n                ok = False\n            if not ok:\n                raise DistutilsOptionError(\n                    \"'%s' must be a list of strings (got %r)\" % (option, val)\n                )\n\n    def reinitialize_command(self, command, reinit_subcommands=0, **kw):\n        cmd = _Command.reinitialize_command(self, command, reinit_subcommands)\n        vars(cmd).update(kw)\n        return cmd\n\n\ndef _find_all_simple(path):\n    \"\"\"\n    Find all files under 'path'\n    \"\"\"\n    results = (\n        os.path.join(base, file)\n        for base, dirs, files in os.walk(path, followlinks=True)\n        for file in files\n    )\n    return filter(os.path.isfile, results)\n\n\ndef findall(dir=os.curdir):\n    \"\"\"\n    Find all files under 'dir' and return the list of full filenames.\n    Unless dir is '.', return full filenames with dir prepended.\n    \"\"\"\n    files = _find_all_simple(dir)\n    if dir == os.curdir:\n        make_rel = functools.partial(os.path.relpath, start=dir)\n        files = map(make_rel, files)\n    return list(files)\n\n\nclass sic(str):\n    \"\"\"Treat this string as-is (https://en.wikipedia.org/wiki/Sic)\"\"\"\n\n\n# Apply monkey patches\nmonkey.patch_all()\n", "path": "setuptools/__init__.py"}], "after_files": [{"content": "import glob\nimport os\nimport subprocess\nimport sys\nimport tempfile\nimport warnings\nfrom distutils import log\nfrom distutils.errors import DistutilsError\n\nimport pkg_resources\nfrom setuptools.wheel import Wheel\nfrom ._deprecation_warning import SetuptoolsDeprecationWarning\n\n\ndef _fixup_find_links(find_links):\n    \"\"\"Ensure find-links option end-up being a list of strings.\"\"\"\n    if isinstance(find_links, str):\n        return find_links.split()\n    assert isinstance(find_links, (tuple, list))\n    return find_links\n\n\ndef fetch_build_egg(dist, req):  # noqa: C901  # is too complex (16)  # FIXME\n    \"\"\"Fetch an egg needed for building.\n\n    Use pip/wheel to fetch/build a wheel.\"\"\"\n    warnings.warn(\n        \"setuptools.installer is deprecated. Requirements should \"\n        \"be satisfied by a PEP 517 installer.\",\n        SetuptoolsDeprecationWarning,\n    )\n    # Warn if wheel is not available\n    try:\n        pkg_resources.get_distribution('wheel')\n    except pkg_resources.DistributionNotFound:\n        dist.announce('WARNING: The wheel package is not available.', log.WARN)\n    # Ignore environment markers; if supplied, it is required.\n    req = strip_marker(req)\n    # Take easy_install options into account, but do not override relevant\n    # pip environment variables (like PIP_INDEX_URL or PIP_QUIET); they'll\n    # take precedence.\n    opts = dist.get_option_dict('easy_install')\n    if 'allow_hosts' in opts:\n        raise DistutilsError('the `allow-hosts` option is not supported '\n                             'when using pip to install requirements.')\n    quiet = 'PIP_QUIET' not in os.environ and 'PIP_VERBOSE' not in os.environ\n    if 'PIP_INDEX_URL' in os.environ:\n        index_url = None\n    elif 'index_url' in opts:\n        index_url = opts['index_url'][1]\n    else:\n        index_url = None\n    find_links = (\n        _fixup_find_links(opts['find_links'][1])[:] if 'find_links' in opts\n        else []\n    )\n    if dist.dependency_links:\n        find_links.extend(dist.dependency_links)\n    eggs_dir = os.path.realpath(dist.get_egg_cache_dir())\n    environment = pkg_resources.Environment()\n    for egg_dist in pkg_resources.find_distributions(eggs_dir):\n        if egg_dist in req and environment.can_add(egg_dist):\n            return egg_dist\n    with tempfile.TemporaryDirectory() as tmpdir:\n        cmd = [\n            sys.executable, '-m', 'pip',\n            '--disable-pip-version-check',\n            'wheel', '--no-deps',\n            '-w', tmpdir,\n        ]\n        if quiet:\n            cmd.append('--quiet')\n        if index_url is not None:\n            cmd.extend(('--index-url', index_url))\n        for link in find_links or []:\n            cmd.extend(('--find-links', link))\n        # If requirement is a PEP 508 direct URL, directly pass\n        # the URL to pip, as `req @ url` does not work on the\n        # command line.\n        cmd.append(req.url or str(req))\n        try:\n            subprocess.check_call(cmd)\n        except subprocess.CalledProcessError as e:\n            raise DistutilsError(str(e)) from e\n        wheel = Wheel(glob.glob(os.path.join(tmpdir, '*.whl'))[0])\n        dist_location = os.path.join(eggs_dir, wheel.egg_name())\n        wheel.install_as_egg(dist_location)\n        dist_metadata = pkg_resources.PathMetadata(\n            dist_location, os.path.join(dist_location, 'EGG-INFO'))\n        dist = pkg_resources.Distribution.from_filename(\n            dist_location, metadata=dist_metadata)\n        return dist\n\n\ndef strip_marker(req):\n    \"\"\"\n    Return a new requirement without the environment marker to avoid\n    calling pip with something like `babel; extra == \"i18n\"`, which\n    would always be ignored.\n    \"\"\"\n    # create a copy to avoid mutating the input\n    req = pkg_resources.Requirement.parse(str(req))\n    req.marker = None\n    return req\n", "path": "setuptools/installer.py"}, {"content": "\"\"\"Extensions to the 'distutils' for large or complex distributions\"\"\"\n\nfrom fnmatch import fnmatchcase\nimport functools\nimport os\nimport re\n\nimport _distutils_hack.override  # noqa: F401\n\nimport distutils.core\nfrom distutils.errors import DistutilsOptionError\nfrom distutils.util import convert_path\n\nfrom ._deprecation_warning import SetuptoolsDeprecationWarning\n\nimport setuptools.version\nfrom setuptools.extension import Extension\nfrom setuptools.dist import Distribution\nfrom setuptools.depends import Require\nfrom . import monkey\n\n\n__all__ = [\n    'setup',\n    'Distribution',\n    'Command',\n    'Extension',\n    'Require',\n    'SetuptoolsDeprecationWarning',\n    'find_packages',\n    'find_namespace_packages',\n]\n\n__version__ = setuptools.version.__version__\n\nbootstrap_install_from = None\n\n\nclass PackageFinder:\n    \"\"\"\n    Generate a list of all Python packages found within a directory\n    \"\"\"\n\n    @classmethod\n    def find(cls, where='.', exclude=(), include=('*',)):\n        \"\"\"Return a list all Python packages found within directory 'where'\n\n        'where' is the root directory which will be searched for packages.  It\n        should be supplied as a \"cross-platform\" (i.e. URL-style) path; it will\n        be converted to the appropriate local path syntax.\n\n        'exclude' is a sequence of package names to exclude; '*' can be used\n        as a wildcard in the names, such that 'foo.*' will exclude all\n        subpackages of 'foo' (but not 'foo' itself).\n\n        'include' is a sequence of package names to include.  If it's\n        specified, only the named packages will be included.  If it's not\n        specified, all found packages will be included.  'include' can contain\n        shell style wildcard patterns just like 'exclude'.\n        \"\"\"\n\n        return list(\n            cls._find_packages_iter(\n                convert_path(where),\n                cls._build_filter('ez_setup', '*__pycache__', *exclude),\n                cls._build_filter(*include),\n            )\n        )\n\n    @classmethod\n    def _find_packages_iter(cls, where, exclude, include):\n        \"\"\"\n        All the packages found in 'where' that pass the 'include' filter, but\n        not the 'exclude' filter.\n        \"\"\"\n        for root, dirs, files in os.walk(where, followlinks=True):\n            # Copy dirs to iterate over it, then empty dirs.\n            all_dirs = dirs[:]\n            dirs[:] = []\n\n            for dir in all_dirs:\n                full_path = os.path.join(root, dir)\n                rel_path = os.path.relpath(full_path, where)\n                package = rel_path.replace(os.path.sep, '.')\n\n                # Skip directory trees that are not valid packages\n                if '.' in dir or not cls._looks_like_package(full_path):\n                    continue\n\n                # Should this package be included?\n                if include(package) and not exclude(package):\n                    yield package\n\n                # Keep searching subdirectories, as there may be more packages\n                # down there, even if the parent was excluded.\n                dirs.append(dir)\n\n    @staticmethod\n    def _looks_like_package(path):\n        \"\"\"Does a directory look like a package?\"\"\"\n        return os.path.isfile(os.path.join(path, '__init__.py'))\n\n    @staticmethod\n    def _build_filter(*patterns):\n        \"\"\"\n        Given a list of patterns, return a callable that will be true only if\n        the input matches at least one of the patterns.\n        \"\"\"\n        return lambda name: any(fnmatchcase(name, pat=pat) for pat in patterns)\n\n\nclass PEP420PackageFinder(PackageFinder):\n    @staticmethod\n    def _looks_like_package(path):\n        return True\n\n\nfind_packages = PackageFinder.find\nfind_namespace_packages = PEP420PackageFinder.find\n\n\ndef _install_setup_requires(attrs):\n    # Note: do not use `setuptools.Distribution` directly, as\n    # our PEP 517 backend patch `distutils.core.Distribution`.\n    class MinimalDistribution(distutils.core.Distribution):\n        \"\"\"\n        A minimal version of a distribution for supporting the\n        fetch_build_eggs interface.\n        \"\"\"\n\n        def __init__(self, attrs):\n            _incl = 'dependency_links', 'setup_requires'\n            filtered = {k: attrs[k] for k in set(_incl) & set(attrs)}\n            distutils.core.Distribution.__init__(self, filtered)\n\n        def finalize_options(self):\n            \"\"\"\n            Disable finalize_options to avoid building the working set.\n            Ref #2158.\n            \"\"\"\n\n    dist = MinimalDistribution(attrs)\n\n    # Honor setup.cfg's options.\n    dist.parse_config_files(ignore_option_errors=True)\n    if dist.setup_requires:\n        dist.fetch_build_eggs(dist.setup_requires)\n\n\ndef setup(**attrs):\n    # Make sure we have any requirements needed to interpret 'attrs'.\n    _install_setup_requires(attrs)\n    return distutils.core.setup(**attrs)\n\n\nsetup.__doc__ = distutils.core.setup.__doc__\n\n\n_Command = monkey.get_unpatched(distutils.core.Command)\n\n\nclass Command(_Command):\n    __doc__ = _Command.__doc__\n\n    command_consumes_arguments = False\n\n    def __init__(self, dist, **kw):\n        \"\"\"\n        Construct the command for dist, updating\n        vars(self) with any keyword parameters.\n        \"\"\"\n        _Command.__init__(self, dist)\n        vars(self).update(kw)\n\n    def _ensure_stringlike(self, option, what, default=None):\n        val = getattr(self, option)\n        if val is None:\n            setattr(self, option, default)\n            return default\n        elif not isinstance(val, str):\n            raise DistutilsOptionError(\n                \"'%s' must be a %s (got `%s`)\" % (option, what, val)\n            )\n        return val\n\n    def ensure_string_list(self, option):\n        r\"\"\"Ensure that 'option' is a list of strings.  If 'option' is\n        currently a string, we split it either on /,\\s*/ or /\\s+/, so\n        \"foo bar baz\", \"foo,bar,baz\", and \"foo,   bar baz\" all become\n        [\"foo\", \"bar\", \"baz\"].\n        \"\"\"\n        val = getattr(self, option)\n        if val is None:\n            return\n        elif isinstance(val, str):\n            setattr(self, option, re.split(r',\\s*|\\s+', val))\n        else:\n            if isinstance(val, list):\n                ok = all(isinstance(v, str) for v in val)\n            else:\n                ok = False\n            if not ok:\n                raise DistutilsOptionError(\n                    \"'%s' must be a list of strings (got %r)\" % (option, val)\n                )\n\n    def reinitialize_command(self, command, reinit_subcommands=0, **kw):\n        cmd = _Command.reinitialize_command(self, command, reinit_subcommands)\n        vars(cmd).update(kw)\n        return cmd\n\n\ndef _find_all_simple(path):\n    \"\"\"\n    Find all files under 'path'\n    \"\"\"\n    results = (\n        os.path.join(base, file)\n        for base, dirs, files in os.walk(path, followlinks=True)\n        for file in files\n    )\n    return filter(os.path.isfile, results)\n\n\ndef findall(dir=os.curdir):\n    \"\"\"\n    Find all files under 'dir' and return the list of full filenames.\n    Unless dir is '.', return full filenames with dir prepended.\n    \"\"\"\n    files = _find_all_simple(dir)\n    if dir == os.curdir:\n        make_rel = functools.partial(os.path.relpath, start=dir)\n        files = map(make_rel, files)\n    return list(files)\n\n\nclass sic(str):\n    \"\"\"Treat this string as-is (https://en.wikipedia.org/wiki/Sic)\"\"\"\n\n\n# Apply monkey patches\nmonkey.patch_all()\n", "path": "setuptools/__init__.py"}]}