|
1 | 1 | import logging
|
2 | 2 | from optparse import Values
|
3 |
| -from typing import Dict, Generator, Iterable, Iterator, List, NamedTuple, Optional |
| 3 | +from typing import Generator, Iterable, Iterator, List, NamedTuple, Optional |
4 | 4 |
|
5 | 5 | from pip._vendor.packaging.utils import canonicalize_name
|
6 | 6 |
|
@@ -61,7 +61,7 @@ class _PackageInfo(NamedTuple):
|
61 | 61 | classifiers: List[str]
|
62 | 62 | summary: str
|
63 | 63 | homepage: str
|
64 |
| - project_urls: Dict[str, str] |
| 64 | + project_urls: List[str] |
65 | 65 | author: str
|
66 | 66 | author_email: str
|
67 | 67 | license: str
|
@@ -121,23 +121,20 @@ def _get_requiring_packages(current_dist: BaseDistribution) -> Iterator[str]:
|
121 | 121 |
|
122 | 122 | metadata = dist.metadata
|
123 | 123 |
|
124 |
| - project_urls = {} |
125 |
| - for url in metadata.get_all("Project-URL", []): |
126 |
| - url_label, url = url.split(",", maxsplit=1) |
127 |
| - project_urls[url_label.strip()] = url.strip() |
128 |
| - |
| 124 | + project_urls = metadata.get_all("Project-URL", []) |
129 | 125 | homepage = metadata.get("Home-page", "")
|
130 | 126 | if not homepage:
|
131 | 127 | # It's common that there is a "homepage" Project-URL, but Home-page
|
132 | 128 | # remains unset (especially as PEP 621 doesn't surface the field).
|
133 | 129 | #
|
134 | 130 | # This logic was taken from PyPI's codebase.
|
135 |
| - for url_label, url in project_urls.items(): |
| 131 | + for url in project_urls: |
| 132 | + url_label, url = url.split(",", maxsplit=1) |
136 | 133 | normalized_label = (
|
137 |
| - url_label.casefold().replace("-", "").replace("_", "") |
| 134 | + url_label.casefold().replace("-", "").replace("_", "").strip() |
138 | 135 | )
|
139 | 136 | if normalized_label == "homepage":
|
140 |
| - homepage = url |
| 137 | + homepage = url.strip() |
141 | 138 | break
|
142 | 139 |
|
143 | 140 | yield _PackageInfo(
|
@@ -200,8 +197,8 @@ def print_results(
|
200 | 197 | for entry in dist.entry_points:
|
201 | 198 | write_output(" %s", entry.strip())
|
202 | 199 | write_output("Project-URLs:")
|
203 |
| - for label, url in dist.project_urls.items(): |
204 |
| - write_output(f" {label}, {url}") |
| 200 | + for project_url in dist.project_urls: |
| 201 | + write_output(" %s", project_url) |
205 | 202 | if list_files:
|
206 | 203 | write_output("Files:")
|
207 | 204 | if dist.files is None:
|
|
0 commit comments