Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions newsfragments/1578.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Restored reading ``Project-URL`` fields into ``DistributionMetadata.project_urls`` when loading ``PKG-INFO`` metadata.
11 changes: 11 additions & 0 deletions setuptools/_core_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@ def _read_list_from_msg(msg: Message, field: str) -> list[str] | None:
return values


def _read_project_urls_from_msg(msg: Message) -> dict[str, str]:
"""Read Message Project-URL fields as a label-to-URL mapping."""
project_urls = _read_list_from_msg(msg, 'project-url') or []
return dict(
(label.strip(), url.strip())
for project_url in project_urls
for label, _, url in (project_url.partition(','),)
)


def _read_payload_from_msg(msg: Message) -> str | None:
value = str(msg.get_payload()).strip()
if value == 'UNKNOWN' or not value:
Expand Down Expand Up @@ -100,6 +110,7 @@ def read_pkg_file(self, file):

self.platforms = _read_list_from_msg(msg, 'platform')
self.classifiers = _read_list_from_msg(msg, 'classifier')
self.project_urls = _read_project_urls_from_msg(msg)

# PEP 314 - these fields only exist in 1.1
if self.metadata_version == Version('1.1'):
Expand Down
5 changes: 1 addition & 4 deletions setuptools/tests/test_core_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,9 @@ def __read_test_cases():
python_requires='>=3.7',
),
),
pytest.param(
(
'Metadata Version 1.2: Project-Url',
params(project_urls=dict(Foo='https://example.bar')),
marks=pytest.mark.xfail(
reason="Issue #1578: project_urls not read",
),
),
(
'Metadata Version 2.1: Long Description Content Type',
Expand Down