We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[Legal] Include the license of all libraries in `_vendor`
### What's the problem this feature will solve?

I'm not a lawyer, but my understanding is that it is not allowed to separate MIT licensed code from its license and copyright.

### Describe the solution you'd like

Include the license of all vendored libraries.

### Alternative Solutions

_No response_

### Additional context

_No response_

### Code of Conduct

- [X] I agree to follow the PSF Code of Conduct

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `pavement.py`
Content:
```
1 import re
2 import sys
3 import subprocess
4 
5 from paver.easy import task, path as Path
6 
7 
8 def remove_all(paths):
9     for path in paths:
10         path.rmtree() if path.isdir() else path.remove()
11 
12 
13 @task
14 def update_vendored():
15     update_pkg_resources()
16     update_setuptools()
17 
18 
19 def rewrite_packaging(pkg_files, new_root):
20     """
21     Rewrite imports in packaging to redirect to vendored copies.
22     """
23     for file in pkg_files.glob('*.py'):
24         text = file.text()
25         text = re.sub(r' (pyparsing)', rf' {new_root}.\1', text)
26         text = text.replace(
27             'from six.moves.urllib import parse',
28             'from urllib import parse',
29         )
30         file.write_text(text)
31 
32 
33 def clean(vendor):
34     """
35     Remove all files out of the vendor directory except the meta
36     data (as pip uninstall doesn't support -t).
37     """
38     remove_all(
39         path
40         for path in vendor.glob('*')
41         if path.basename() != 'vendored.txt'
42     )
43 
44 
45 def install(vendor):
46     clean(vendor)
47     install_args = [
48         sys.executable,
49         '-m', 'pip',
50         'install',
51         '-r', str(vendor / 'vendored.txt'),
52         '-t', str(vendor),
53     ]
54     subprocess.check_call(install_args)
55     remove_all(vendor.glob('*.dist-info'))
56     remove_all(vendor.glob('*.egg-info'))
57     remove_all(vendor.glob('six.py'))
58     (vendor / '__init__.py').write_text('')
59 
60 
61 def update_pkg_resources():
62     vendor = Path('pkg_resources/_vendor')
63     install(vendor)
64     rewrite_packaging(vendor / 'packaging', 'pkg_resources.extern')
65 
66 
67 def update_setuptools():
68     vendor = Path('setuptools/_vendor')
69     install(vendor)
70     rewrite_packaging(vendor / 'packaging', 'setuptools.extern')
71
```
--- 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/pavement.py b/pavement.py
--- a/pavement.py
+++ b/pavement.py
@@ -1,6 +1,7 @@
 import re
 import sys
 import subprocess
+from fnmatch import fnmatch
 
 from paver.easy import task, path as Path
 
@@ -52,12 +53,43 @@
         '-t', str(vendor),
     ]
     subprocess.check_call(install_args)
+    move_licenses(vendor)
     remove_all(vendor.glob('*.dist-info'))
     remove_all(vendor.glob('*.egg-info'))
     remove_all(vendor.glob('six.py'))
     (vendor / '__init__.py').write_text('')
 
 
+def move_licenses(vendor):
+    license_patterns = ("*LICEN[CS]E*", "COPYING*", "NOTICE*", "AUTHORS*")
+    licenses = (
+        entry
+        for path in vendor.glob("*.dist-info")
+        for entry in path.glob("*")
+        if any(fnmatch(str(entry), p) for p in license_patterns)
+    )
+    for file in licenses:
+        file.move(_find_license_dest(file, vendor))
+
+
+def _find_license_dest(license_file, vendor):
+    basename = license_file.basename()
+    pkg = license_file.dirname().basename().replace(".dist-info", "")
+    parts = pkg.split("-")
+    acc = []
+    for part in parts:
+        # Find actual name from normalized name + version
+        acc.append(part)
+        for option in ("_".join(acc), "-".join(acc), ".".join(acc)):
+            candidate = vendor / option
+            if candidate.isdir():
+                return candidate / basename
+            if Path(f"{candidate}.py").isfile():
+                return Path(f"{candidate}.{basename}")
+
+    raise FileNotFoundError(f"No destination found for {license_file}")
+
+
 def update_pkg_resources():
     vendor = Path('pkg_resources/_vendor')
     install(vendor)

{"golden_diff": "diff --git a/pavement.py b/pavement.py\n--- a/pavement.py\n+++ b/pavement.py\n@@ -1,6 +1,7 @@\n import re\n import sys\n import subprocess\n+from fnmatch import fnmatch\n \n from paver.easy import task, path as Path\n \n@@ -52,12 +53,43 @@\n         '-t', str(vendor),\n     ]\n     subprocess.check_call(install_args)\n+    move_licenses(vendor)\n     remove_all(vendor.glob('*.dist-info'))\n     remove_all(vendor.glob('*.egg-info'))\n     remove_all(vendor.glob('six.py'))\n     (vendor / '__init__.py').write_text('')\n \n \n+def move_licenses(vendor):\n+    license_patterns = (\"*LICEN[CS]E*\", \"COPYING*\", \"NOTICE*\", \"AUTHORS*\")\n+    licenses = (\n+        entry\n+        for path in vendor.glob(\"*.dist-info\")\n+        for entry in path.glob(\"*\")\n+        if any(fnmatch(str(entry), p) for p in license_patterns)\n+    )\n+    for file in licenses:\n+        file.move(_find_license_dest(file, vendor))\n+\n+\n+def _find_license_dest(license_file, vendor):\n+    basename = license_file.basename()\n+    pkg = license_file.dirname().basename().replace(\".dist-info\", \"\")\n+    parts = pkg.split(\"-\")\n+    acc = []\n+    for part in parts:\n+        # Find actual name from normalized name + version\n+        acc.append(part)\n+        for option in (\"_\".join(acc), \"-\".join(acc), \".\".join(acc)):\n+            candidate = vendor / option\n+            if candidate.isdir():\n+                return candidate / basename\n+            if Path(f\"{candidate}.py\").isfile():\n+                return Path(f\"{candidate}.{basename}\")\n+\n+    raise FileNotFoundError(f\"No destination found for {license_file}\")\n+\n+\n def update_pkg_resources():\n     vendor = Path('pkg_resources/_vendor')\n     install(vendor)\n", "issue": "[Legal] Include the license of all libraries in `_vendor`\n### What's the problem this feature will solve?\n\nI'm not a lawyer, but my understanding is that it is not allowed to separate MIT licensed code from its license and copyright.\n\n### Describe the solution you'd like\n\nInclude the license of all vendored libraries.\n\n### Alternative Solutions\n\n_No response_\n\n### Additional context\n\n_No response_\n\n### Code of Conduct\n\n- [X] I agree to follow the PSF Code of Conduct\n", "before_files": [{"content": "import re\nimport sys\nimport subprocess\n\nfrom paver.easy import task, path as Path\n\n\ndef remove_all(paths):\n    for path in paths:\n        path.rmtree() if path.isdir() else path.remove()\n\n\n@task\ndef update_vendored():\n    update_pkg_resources()\n    update_setuptools()\n\n\ndef rewrite_packaging(pkg_files, new_root):\n    \"\"\"\n    Rewrite imports in packaging to redirect to vendored copies.\n    \"\"\"\n    for file in pkg_files.glob('*.py'):\n        text = file.text()\n        text = re.sub(r' (pyparsing)', rf' {new_root}.\\1', text)\n        text = text.replace(\n            'from six.moves.urllib import parse',\n            'from urllib import parse',\n        )\n        file.write_text(text)\n\n\ndef clean(vendor):\n    \"\"\"\n    Remove all files out of the vendor directory except the meta\n    data (as pip uninstall doesn't support -t).\n    \"\"\"\n    remove_all(\n        path\n        for path in vendor.glob('*')\n        if path.basename() != 'vendored.txt'\n    )\n\n\ndef install(vendor):\n    clean(vendor)\n    install_args = [\n        sys.executable,\n        '-m', 'pip',\n        'install',\n        '-r', str(vendor / 'vendored.txt'),\n        '-t', str(vendor),\n    ]\n    subprocess.check_call(install_args)\n    remove_all(vendor.glob('*.dist-info'))\n    remove_all(vendor.glob('*.egg-info'))\n    remove_all(vendor.glob('six.py'))\n    (vendor / '__init__.py').write_text('')\n\n\ndef update_pkg_resources():\n    vendor = Path('pkg_resources/_vendor')\n    install(vendor)\n    rewrite_packaging(vendor / 'packaging', 'pkg_resources.extern')\n\n\ndef update_setuptools():\n    vendor = Path('setuptools/_vendor')\n    install(vendor)\n    rewrite_packaging(vendor / 'packaging', 'setuptools.extern')\n", "path": "pavement.py"}], "after_files": [{"content": "import re\nimport sys\nimport subprocess\nfrom fnmatch import fnmatch\n\nfrom paver.easy import task, path as Path\n\n\ndef remove_all(paths):\n    for path in paths:\n        path.rmtree() if path.isdir() else path.remove()\n\n\n@task\ndef update_vendored():\n    update_pkg_resources()\n    update_setuptools()\n\n\ndef rewrite_packaging(pkg_files, new_root):\n    \"\"\"\n    Rewrite imports in packaging to redirect to vendored copies.\n    \"\"\"\n    for file in pkg_files.glob('*.py'):\n        text = file.text()\n        text = re.sub(r' (pyparsing)', rf' {new_root}.\\1', text)\n        text = text.replace(\n            'from six.moves.urllib import parse',\n            'from urllib import parse',\n        )\n        file.write_text(text)\n\n\ndef clean(vendor):\n    \"\"\"\n    Remove all files out of the vendor directory except the meta\n    data (as pip uninstall doesn't support -t).\n    \"\"\"\n    remove_all(\n        path\n        for path in vendor.glob('*')\n        if path.basename() != 'vendored.txt'\n    )\n\n\ndef install(vendor):\n    clean(vendor)\n    install_args = [\n        sys.executable,\n        '-m', 'pip',\n        'install',\n        '-r', str(vendor / 'vendored.txt'),\n        '-t', str(vendor),\n    ]\n    subprocess.check_call(install_args)\n    move_licenses(vendor)\n    remove_all(vendor.glob('*.dist-info'))\n    remove_all(vendor.glob('*.egg-info'))\n    remove_all(vendor.glob('six.py'))\n    (vendor / '__init__.py').write_text('')\n\n\ndef move_licenses(vendor):\n    license_patterns = (\"*LICEN[CS]E*\", \"COPYING*\", \"NOTICE*\", \"AUTHORS*\")\n    licenses = (\n        entry\n        for path in vendor.glob(\"*.dist-info\")\n        for entry in path.glob(\"*\")\n        if any(fnmatch(str(entry), p) for p in license_patterns)\n    )\n    for file in licenses:\n        file.move(_find_license_dest(file, vendor))\n\n\ndef _find_license_dest(license_file, vendor):\n    basename = license_file.basename()\n    pkg = license_file.dirname().basename().replace(\".dist-info\", \"\")\n    parts = pkg.split(\"-\")\n    acc = []\n    for part in parts:\n        # Find actual name from normalized name + version\n        acc.append(part)\n        for option in (\"_\".join(acc), \"-\".join(acc), \".\".join(acc)):\n            candidate = vendor / option\n            if candidate.isdir():\n                return candidate / basename\n            if Path(f\"{candidate}.py\").isfile():\n                return Path(f\"{candidate}.{basename}\")\n\n    raise FileNotFoundError(f\"No destination found for {license_file}\")\n\n\ndef update_pkg_resources():\n    vendor = Path('pkg_resources/_vendor')\n    install(vendor)\n    rewrite_packaging(vendor / 'packaging', 'pkg_resources.extern')\n\n\ndef update_setuptools():\n    vendor = Path('setuptools/_vendor')\n    install(vendor)\n    rewrite_packaging(vendor / 'packaging', 'setuptools.extern')\n", "path": "pavement.py"}]}