We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
AssertionError on len(sdists) == 1 when sdist format is zip
In some Windows projects, users expect sdists to be released in zip form. For that reason, I've added the following to a project's setup.cfg:

```
[sdist]
formats=zip
```

With this setting in place, performing a `pep517.build .` on such a project results in the following traceback:

```
Traceback (most recent call last):
  File "/Users/jaraco/code/main/jaraco.video/.tox/release/lib/python3.7/site-packages/pep517/_in_process.py", line 207, in <module>
    main()
  File "/Users/jaraco/code/main/jaraco.video/.tox/release/lib/python3.7/site-packages/pep517/_in_process.py", line 197, in main
    json_out['return_val'] = hook(**hook_input['kwargs'])
  File "/Users/jaraco/code/main/jaraco.video/.tox/release/lib/python3.7/site-packages/pep517/_in_process.py", line 170, in build_sdist
    return backend.build_sdist(sdist_directory, config_settings)
  File "/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pep517-build-env-rgz_zb4_/lib/python3.7/site-packages/setuptools/build_meta.py", line 181, in build_sdist
    assert len(sdists) == 1
AssertionError
```

Even though the output from building the sdist was seen above. I suspect the builder expects the sdist to have a particular extension.
AssertionError on len(sdists) == 1 when sdist format is zip
In some Windows projects, users expect sdists to be released in zip form. For that reason, I've added the following to a project's setup.cfg:

```
[sdist]
formats=zip
```

With this setting in place, performing a `pep517.build .` on such a project results in the following traceback:

```
Traceback (most recent call last):
  File "/Users/jaraco/code/main/jaraco.video/.tox/release/lib/python3.7/site-packages/pep517/_in_process.py", line 207, in <module>
    main()
  File "/Users/jaraco/code/main/jaraco.video/.tox/release/lib/python3.7/site-packages/pep517/_in_process.py", line 197, in main
    json_out['return_val'] = hook(**hook_input['kwargs'])
  File "/Users/jaraco/code/main/jaraco.video/.tox/release/lib/python3.7/site-packages/pep517/_in_process.py", line 170, in build_sdist
    return backend.build_sdist(sdist_directory, config_settings)
  File "/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pep517-build-env-rgz_zb4_/lib/python3.7/site-packages/setuptools/build_meta.py", line 181, in build_sdist
    assert len(sdists) == 1
AssertionError
```

Even though the output from building the sdist was seen above. I suspect the builder expects the sdist to have a particular extension.

--- 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/build_meta.py`
Content:
```
1 """A PEP 517 interface to setuptools
2 
3 Previously, when a user or a command line tool (let's call it a "frontend")
4 needed to make a request of setuptools to take a certain action, for
5 example, generating a list of installation requirements, the frontend would
6 would call "setup.py egg_info" or "setup.py bdist_wheel" on the command line.
7 
8 PEP 517 defines a different method of interfacing with setuptools. Rather
9 than calling "setup.py" directly, the frontend should:
10 
11   1. Set the current directory to the directory with a setup.py file
12   2. Import this module into a safe python interpreter (one in which
13      setuptools can potentially set global variables or crash hard).
14   3. Call one of the functions defined in PEP 517.
15 
16 What each function does is defined in PEP 517. However, here is a "casual"
17 definition of the functions (this definition should not be relied on for
18 bug reports or API stability):
19 
20   - `build_wheel`: build a wheel in the folder and return the basename
21   - `get_requires_for_build_wheel`: get the `setup_requires` to build
22   - `prepare_metadata_for_build_wheel`: get the `install_requires`
23   - `build_sdist`: build an sdist in the folder and return the basename
24   - `get_requires_for_build_sdist`: get the `setup_requires` to build
25 
26 Again, this is not a formal definition! Just a "taste" of the module.
27 """
28 
29 import os
30 import sys
31 import tokenize
32 import shutil
33 import contextlib
34 
35 import setuptools
36 import distutils
37 
38 
39 class SetupRequirementsError(BaseException):
40     def __init__(self, specifiers):
41         self.specifiers = specifiers
42 
43 
44 class Distribution(setuptools.dist.Distribution):
45     def fetch_build_eggs(self, specifiers):
46         raise SetupRequirementsError(specifiers)
47 
48     @classmethod
49     @contextlib.contextmanager
50     def patch(cls):
51         """
52         Replace
53         distutils.dist.Distribution with this class
54         for the duration of this context.
55         """
56         orig = distutils.core.Distribution
57         distutils.core.Distribution = cls
58         try:
59             yield
60         finally:
61             distutils.core.Distribution = orig
62 
63 
64 def _to_str(s):
65     """
66     Convert a filename to a string (on Python 2, explicitly
67     a byte string, not Unicode) as distutils checks for the
68     exact type str.
69     """
70     if sys.version_info[0] == 2 and not isinstance(s, str):
71         # Assume it's Unicode, as that's what the PEP says
72         # should be provided.
73         return s.encode(sys.getfilesystemencoding())
74     return s
75 
76 
77 def _run_setup(setup_script='setup.py'):
78     # Note that we can reuse our build directory between calls
79     # Correctness comes first, then optimization later
80     __file__ = setup_script
81     __name__ = '__main__'
82     f = getattr(tokenize, 'open', open)(__file__)
83     code = f.read().replace('\\r\\n', '\\n')
84     f.close()
85     exec(compile(code, __file__, 'exec'), locals())
86 
87 
88 def _fix_config(config_settings):
89     config_settings = config_settings or {}
90     config_settings.setdefault('--global-option', [])
91     return config_settings
92 
93 
94 def _get_build_requires(config_settings, requirements):
95     config_settings = _fix_config(config_settings)
96 
97     sys.argv = sys.argv[:1] + ['egg_info'] + \
98         config_settings["--global-option"]
99     try:
100         with Distribution.patch():
101             _run_setup()
102     except SetupRequirementsError as e:
103         requirements += e.specifiers
104 
105     return requirements
106 
107 
108 def _get_immediate_subdirectories(a_dir):
109     return [name for name in os.listdir(a_dir)
110             if os.path.isdir(os.path.join(a_dir, name))]
111 
112 
113 def get_requires_for_build_wheel(config_settings=None):
114     config_settings = _fix_config(config_settings)
115     return _get_build_requires(config_settings, requirements=['wheel'])
116 
117 
118 def get_requires_for_build_sdist(config_settings=None):
119     config_settings = _fix_config(config_settings)
120     return _get_build_requires(config_settings, requirements=[])
121 
122 
123 def prepare_metadata_for_build_wheel(metadata_directory, config_settings=None):
124     sys.argv = sys.argv[:1] + ['dist_info', '--egg-base', _to_str(metadata_directory)]
125     _run_setup()
126 
127     dist_info_directory = metadata_directory
128     while True:
129         dist_infos = [f for f in os.listdir(dist_info_directory)
130                       if f.endswith('.dist-info')]
131 
132         if len(dist_infos) == 0 and \
133                 len(_get_immediate_subdirectories(dist_info_directory)) == 1:
134             dist_info_directory = os.path.join(
135                 dist_info_directory, os.listdir(dist_info_directory)[0])
136             continue
137 
138         assert len(dist_infos) == 1
139         break
140 
141     # PEP 517 requires that the .dist-info directory be placed in the
142     # metadata_directory. To comply, we MUST copy the directory to the root
143     if dist_info_directory != metadata_directory:
144         shutil.move(
145             os.path.join(dist_info_directory, dist_infos[0]),
146             metadata_directory)
147         shutil.rmtree(dist_info_directory, ignore_errors=True)
148 
149     return dist_infos[0]
150 
151 
152 def build_wheel(wheel_directory, config_settings=None,
153                 metadata_directory=None):
154     config_settings = _fix_config(config_settings)
155     wheel_directory = os.path.abspath(wheel_directory)
156     sys.argv = sys.argv[:1] + ['bdist_wheel'] + \
157         config_settings["--global-option"]
158     _run_setup()
159     if wheel_directory != 'dist':
160         shutil.rmtree(wheel_directory)
161         shutil.copytree('dist', wheel_directory)
162 
163     wheels = [f for f in os.listdir(wheel_directory)
164               if f.endswith('.whl')]
165 
166     assert len(wheels) == 1
167     return wheels[0]
168 
169 
170 def build_sdist(sdist_directory, config_settings=None):
171     config_settings = _fix_config(config_settings)
172     sdist_directory = os.path.abspath(sdist_directory)
173     sys.argv = sys.argv[:1] + ['sdist'] + \
174         config_settings["--global-option"] + \
175         ["--dist-dir", sdist_directory]
176     _run_setup()
177 
178     sdists = [f for f in os.listdir(sdist_directory)
179               if f.endswith('.tar.gz')]
180 
181     assert len(sdists) == 1
182     return sdists[0]
183
```
--- 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/build_meta.py b/setuptools/build_meta.py
--- a/setuptools/build_meta.py
+++ b/setuptools/build_meta.py
@@ -170,7 +170,7 @@
 def build_sdist(sdist_directory, config_settings=None):
     config_settings = _fix_config(config_settings)
     sdist_directory = os.path.abspath(sdist_directory)
-    sys.argv = sys.argv[:1] + ['sdist'] + \
+    sys.argv = sys.argv[:1] + ['sdist', '--formats', 'gztar'] + \
         config_settings["--global-option"] + \
         ["--dist-dir", sdist_directory]
     _run_setup()

{"golden_diff": "diff --git a/setuptools/build_meta.py b/setuptools/build_meta.py\n--- a/setuptools/build_meta.py\n+++ b/setuptools/build_meta.py\n@@ -170,7 +170,7 @@\n def build_sdist(sdist_directory, config_settings=None):\n     config_settings = _fix_config(config_settings)\n     sdist_directory = os.path.abspath(sdist_directory)\n-    sys.argv = sys.argv[:1] + ['sdist'] + \\\n+    sys.argv = sys.argv[:1] + ['sdist', '--formats', 'gztar'] + \\\n         config_settings[\"--global-option\"] + \\\n         [\"--dist-dir\", sdist_directory]\n     _run_setup()\n", "issue": "AssertionError on len(sdists) == 1 when sdist format is zip\nIn some Windows projects, users expect sdists to be released in zip form. For that reason, I've added the following to a project's setup.cfg:\r\n\r\n```\r\n[sdist]\r\nformats=zip\r\n```\r\n\r\nWith this setting in place, performing a `pep517.build .` on such a project results in the following traceback:\r\n\r\n```\r\nTraceback (most recent call last):\r\n  File \"/Users/jaraco/code/main/jaraco.video/.tox/release/lib/python3.7/site-packages/pep517/_in_process.py\", line 207, in <module>\r\n    main()\r\n  File \"/Users/jaraco/code/main/jaraco.video/.tox/release/lib/python3.7/site-packages/pep517/_in_process.py\", line 197, in main\r\n    json_out['return_val'] = hook(**hook_input['kwargs'])\r\n  File \"/Users/jaraco/code/main/jaraco.video/.tox/release/lib/python3.7/site-packages/pep517/_in_process.py\", line 170, in build_sdist\r\n    return backend.build_sdist(sdist_directory, config_settings)\r\n  File \"/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pep517-build-env-rgz_zb4_/lib/python3.7/site-packages/setuptools/build_meta.py\", line 181, in build_sdist\r\n    assert len(sdists) == 1\r\nAssertionError\r\n```\r\n\r\nEven though the output from building the sdist was seen above. I suspect the builder expects the sdist to have a particular extension.\nAssertionError on len(sdists) == 1 when sdist format is zip\nIn some Windows projects, users expect sdists to be released in zip form. For that reason, I've added the following to a project's setup.cfg:\r\n\r\n```\r\n[sdist]\r\nformats=zip\r\n```\r\n\r\nWith this setting in place, performing a `pep517.build .` on such a project results in the following traceback:\r\n\r\n```\r\nTraceback (most recent call last):\r\n  File \"/Users/jaraco/code/main/jaraco.video/.tox/release/lib/python3.7/site-packages/pep517/_in_process.py\", line 207, in <module>\r\n    main()\r\n  File \"/Users/jaraco/code/main/jaraco.video/.tox/release/lib/python3.7/site-packages/pep517/_in_process.py\", line 197, in main\r\n    json_out['return_val'] = hook(**hook_input['kwargs'])\r\n  File \"/Users/jaraco/code/main/jaraco.video/.tox/release/lib/python3.7/site-packages/pep517/_in_process.py\", line 170, in build_sdist\r\n    return backend.build_sdist(sdist_directory, config_settings)\r\n  File \"/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pep517-build-env-rgz_zb4_/lib/python3.7/site-packages/setuptools/build_meta.py\", line 181, in build_sdist\r\n    assert len(sdists) == 1\r\nAssertionError\r\n```\r\n\r\nEven though the output from building the sdist was seen above. I suspect the builder expects the sdist to have a particular extension.\n", "before_files": [{"content": "\"\"\"A PEP 517 interface to setuptools\n\nPreviously, when a user or a command line tool (let's call it a \"frontend\")\nneeded to make a request of setuptools to take a certain action, for\nexample, generating a list of installation requirements, the frontend would\nwould call \"setup.py egg_info\" or \"setup.py bdist_wheel\" on the command line.\n\nPEP 517 defines a different method of interfacing with setuptools. Rather\nthan calling \"setup.py\" directly, the frontend should:\n\n  1. Set the current directory to the directory with a setup.py file\n  2. Import this module into a safe python interpreter (one in which\n     setuptools can potentially set global variables or crash hard).\n  3. Call one of the functions defined in PEP 517.\n\nWhat each function does is defined in PEP 517. However, here is a \"casual\"\ndefinition of the functions (this definition should not be relied on for\nbug reports or API stability):\n\n  - `build_wheel`: build a wheel in the folder and return the basename\n  - `get_requires_for_build_wheel`: get the `setup_requires` to build\n  - `prepare_metadata_for_build_wheel`: get the `install_requires`\n  - `build_sdist`: build an sdist in the folder and return the basename\n  - `get_requires_for_build_sdist`: get the `setup_requires` to build\n\nAgain, this is not a formal definition! Just a \"taste\" of the module.\n\"\"\"\n\nimport os\nimport sys\nimport tokenize\nimport shutil\nimport contextlib\n\nimport setuptools\nimport distutils\n\n\nclass SetupRequirementsError(BaseException):\n    def __init__(self, specifiers):\n        self.specifiers = specifiers\n\n\nclass Distribution(setuptools.dist.Distribution):\n    def fetch_build_eggs(self, specifiers):\n        raise SetupRequirementsError(specifiers)\n\n    @classmethod\n    @contextlib.contextmanager\n    def patch(cls):\n        \"\"\"\n        Replace\n        distutils.dist.Distribution with this class\n        for the duration of this context.\n        \"\"\"\n        orig = distutils.core.Distribution\n        distutils.core.Distribution = cls\n        try:\n            yield\n        finally:\n            distutils.core.Distribution = orig\n\n\ndef _to_str(s):\n    \"\"\"\n    Convert a filename to a string (on Python 2, explicitly\n    a byte string, not Unicode) as distutils checks for the\n    exact type str.\n    \"\"\"\n    if sys.version_info[0] == 2 and not isinstance(s, str):\n        # Assume it's Unicode, as that's what the PEP says\n        # should be provided.\n        return s.encode(sys.getfilesystemencoding())\n    return s\n\n\ndef _run_setup(setup_script='setup.py'):\n    # Note that we can reuse our build directory between calls\n    # Correctness comes first, then optimization later\n    __file__ = setup_script\n    __name__ = '__main__'\n    f = getattr(tokenize, 'open', open)(__file__)\n    code = f.read().replace('\\\\r\\\\n', '\\\\n')\n    f.close()\n    exec(compile(code, __file__, 'exec'), locals())\n\n\ndef _fix_config(config_settings):\n    config_settings = config_settings or {}\n    config_settings.setdefault('--global-option', [])\n    return config_settings\n\n\ndef _get_build_requires(config_settings, requirements):\n    config_settings = _fix_config(config_settings)\n\n    sys.argv = sys.argv[:1] + ['egg_info'] + \\\n        config_settings[\"--global-option\"]\n    try:\n        with Distribution.patch():\n            _run_setup()\n    except SetupRequirementsError as e:\n        requirements += e.specifiers\n\n    return requirements\n\n\ndef _get_immediate_subdirectories(a_dir):\n    return [name for name in os.listdir(a_dir)\n            if os.path.isdir(os.path.join(a_dir, name))]\n\n\ndef get_requires_for_build_wheel(config_settings=None):\n    config_settings = _fix_config(config_settings)\n    return _get_build_requires(config_settings, requirements=['wheel'])\n\n\ndef get_requires_for_build_sdist(config_settings=None):\n    config_settings = _fix_config(config_settings)\n    return _get_build_requires(config_settings, requirements=[])\n\n\ndef prepare_metadata_for_build_wheel(metadata_directory, config_settings=None):\n    sys.argv = sys.argv[:1] + ['dist_info', '--egg-base', _to_str(metadata_directory)]\n    _run_setup()\n\n    dist_info_directory = metadata_directory\n    while True:\n        dist_infos = [f for f in os.listdir(dist_info_directory)\n                      if f.endswith('.dist-info')]\n\n        if len(dist_infos) == 0 and \\\n                len(_get_immediate_subdirectories(dist_info_directory)) == 1:\n            dist_info_directory = os.path.join(\n                dist_info_directory, os.listdir(dist_info_directory)[0])\n            continue\n\n        assert len(dist_infos) == 1\n        break\n\n    # PEP 517 requires that the .dist-info directory be placed in the\n    # metadata_directory. To comply, we MUST copy the directory to the root\n    if dist_info_directory != metadata_directory:\n        shutil.move(\n            os.path.join(dist_info_directory, dist_infos[0]),\n            metadata_directory)\n        shutil.rmtree(dist_info_directory, ignore_errors=True)\n\n    return dist_infos[0]\n\n\ndef build_wheel(wheel_directory, config_settings=None,\n                metadata_directory=None):\n    config_settings = _fix_config(config_settings)\n    wheel_directory = os.path.abspath(wheel_directory)\n    sys.argv = sys.argv[:1] + ['bdist_wheel'] + \\\n        config_settings[\"--global-option\"]\n    _run_setup()\n    if wheel_directory != 'dist':\n        shutil.rmtree(wheel_directory)\n        shutil.copytree('dist', wheel_directory)\n\n    wheels = [f for f in os.listdir(wheel_directory)\n              if f.endswith('.whl')]\n\n    assert len(wheels) == 1\n    return wheels[0]\n\n\ndef build_sdist(sdist_directory, config_settings=None):\n    config_settings = _fix_config(config_settings)\n    sdist_directory = os.path.abspath(sdist_directory)\n    sys.argv = sys.argv[:1] + ['sdist'] + \\\n        config_settings[\"--global-option\"] + \\\n        [\"--dist-dir\", sdist_directory]\n    _run_setup()\n\n    sdists = [f for f in os.listdir(sdist_directory)\n              if f.endswith('.tar.gz')]\n\n    assert len(sdists) == 1\n    return sdists[0]\n", "path": "setuptools/build_meta.py"}], "after_files": [{"content": "\"\"\"A PEP 517 interface to setuptools\n\nPreviously, when a user or a command line tool (let's call it a \"frontend\")\nneeded to make a request of setuptools to take a certain action, for\nexample, generating a list of installation requirements, the frontend would\nwould call \"setup.py egg_info\" or \"setup.py bdist_wheel\" on the command line.\n\nPEP 517 defines a different method of interfacing with setuptools. Rather\nthan calling \"setup.py\" directly, the frontend should:\n\n  1. Set the current directory to the directory with a setup.py file\n  2. Import this module into a safe python interpreter (one in which\n     setuptools can potentially set global variables or crash hard).\n  3. Call one of the functions defined in PEP 517.\n\nWhat each function does is defined in PEP 517. However, here is a \"casual\"\ndefinition of the functions (this definition should not be relied on for\nbug reports or API stability):\n\n  - `build_wheel`: build a wheel in the folder and return the basename\n  - `get_requires_for_build_wheel`: get the `setup_requires` to build\n  - `prepare_metadata_for_build_wheel`: get the `install_requires`\n  - `build_sdist`: build an sdist in the folder and return the basename\n  - `get_requires_for_build_sdist`: get the `setup_requires` to build\n\nAgain, this is not a formal definition! Just a \"taste\" of the module.\n\"\"\"\n\nimport os\nimport sys\nimport tokenize\nimport shutil\nimport contextlib\n\nimport setuptools\nimport distutils\n\n\nclass SetupRequirementsError(BaseException):\n    def __init__(self, specifiers):\n        self.specifiers = specifiers\n\n\nclass Distribution(setuptools.dist.Distribution):\n    def fetch_build_eggs(self, specifiers):\n        raise SetupRequirementsError(specifiers)\n\n    @classmethod\n    @contextlib.contextmanager\n    def patch(cls):\n        \"\"\"\n        Replace\n        distutils.dist.Distribution with this class\n        for the duration of this context.\n        \"\"\"\n        orig = distutils.core.Distribution\n        distutils.core.Distribution = cls\n        try:\n            yield\n        finally:\n            distutils.core.Distribution = orig\n\n\ndef _to_str(s):\n    \"\"\"\n    Convert a filename to a string (on Python 2, explicitly\n    a byte string, not Unicode) as distutils checks for the\n    exact type str.\n    \"\"\"\n    if sys.version_info[0] == 2 and not isinstance(s, str):\n        # Assume it's Unicode, as that's what the PEP says\n        # should be provided.\n        return s.encode(sys.getfilesystemencoding())\n    return s\n\n\ndef _run_setup(setup_script='setup.py'):\n    # Note that we can reuse our build directory between calls\n    # Correctness comes first, then optimization later\n    __file__ = setup_script\n    __name__ = '__main__'\n    f = getattr(tokenize, 'open', open)(__file__)\n    code = f.read().replace('\\\\r\\\\n', '\\\\n')\n    f.close()\n    exec(compile(code, __file__, 'exec'), locals())\n\n\ndef _fix_config(config_settings):\n    config_settings = config_settings or {}\n    config_settings.setdefault('--global-option', [])\n    return config_settings\n\n\ndef _get_build_requires(config_settings, requirements):\n    config_settings = _fix_config(config_settings)\n\n    sys.argv = sys.argv[:1] + ['egg_info'] + \\\n        config_settings[\"--global-option\"]\n    try:\n        with Distribution.patch():\n            _run_setup()\n    except SetupRequirementsError as e:\n        requirements += e.specifiers\n\n    return requirements\n\n\ndef _get_immediate_subdirectories(a_dir):\n    return [name for name in os.listdir(a_dir)\n            if os.path.isdir(os.path.join(a_dir, name))]\n\n\ndef get_requires_for_build_wheel(config_settings=None):\n    config_settings = _fix_config(config_settings)\n    return _get_build_requires(config_settings, requirements=['wheel'])\n\n\ndef get_requires_for_build_sdist(config_settings=None):\n    config_settings = _fix_config(config_settings)\n    return _get_build_requires(config_settings, requirements=[])\n\n\ndef prepare_metadata_for_build_wheel(metadata_directory, config_settings=None):\n    sys.argv = sys.argv[:1] + ['dist_info', '--egg-base', _to_str(metadata_directory)]\n    _run_setup()\n\n    dist_info_directory = metadata_directory\n    while True:\n        dist_infos = [f for f in os.listdir(dist_info_directory)\n                      if f.endswith('.dist-info')]\n\n        if len(dist_infos) == 0 and \\\n                len(_get_immediate_subdirectories(dist_info_directory)) == 1:\n            dist_info_directory = os.path.join(\n                dist_info_directory, os.listdir(dist_info_directory)[0])\n            continue\n\n        assert len(dist_infos) == 1\n        break\n\n    # PEP 517 requires that the .dist-info directory be placed in the\n    # metadata_directory. To comply, we MUST copy the directory to the root\n    if dist_info_directory != metadata_directory:\n        shutil.move(\n            os.path.join(dist_info_directory, dist_infos[0]),\n            metadata_directory)\n        shutil.rmtree(dist_info_directory, ignore_errors=True)\n\n    return dist_infos[0]\n\n\ndef build_wheel(wheel_directory, config_settings=None,\n                metadata_directory=None):\n    config_settings = _fix_config(config_settings)\n    wheel_directory = os.path.abspath(wheel_directory)\n    sys.argv = sys.argv[:1] + ['bdist_wheel'] + \\\n        config_settings[\"--global-option\"]\n    _run_setup()\n    if wheel_directory != 'dist':\n        shutil.rmtree(wheel_directory)\n        shutil.copytree('dist', wheel_directory)\n\n    wheels = [f for f in os.listdir(wheel_directory)\n              if f.endswith('.whl')]\n\n    assert len(wheels) == 1\n    return wheels[0]\n\n\ndef build_sdist(sdist_directory, config_settings=None):\n    config_settings = _fix_config(config_settings)\n    sdist_directory = os.path.abspath(sdist_directory)\n    sys.argv = sys.argv[:1] + ['sdist', '--formats', 'gztar'] + \\\n        config_settings[\"--global-option\"] + \\\n        [\"--dist-dir\", sdist_directory]\n    _run_setup()\n\n    sdists = [f for f in os.listdir(sdist_directory)\n              if f.endswith('.tar.gz')]\n\n    assert len(sdists) == 1\n    return sdists[0]\n", "path": "setuptools/build_meta.py"}]}