Skip to content

Commit 9cb9d4e

Browse files
woodruffwpfmoore
andauthored
PEP 753: Updates (#4010)
Signed-off-by: William Woodruff <[email protected]> Co-authored-by: Paul Moore <[email protected]>
1 parent ada0f55 commit 9cb9d4e

File tree

1 file changed

+76
-33
lines changed

1 file changed

+76
-33
lines changed

peps/pep-0753.rst

Lines changed: 76 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@ Post-History: `26-Aug-2024 <https://discuss.python.org/t/core-metadata-should-ho
1515
Abstract
1616
========
1717

18-
This PEP recommends two discrete changes to handling of core metadata by
19-
indices, such as PyPI:
18+
This PEP recommends two discrete changes to the processing of core metadata by
19+
indices (such as PyPI) and other core metadata consumers:
2020

2121
* Deprecation of the ``Home-page`` and ``Download-URL`` fields in favor of
2222
their ``Project-URL`` equivalents;
23-
* A set of conventions for normalizing and assigning semantics to
24-
``Project-URL`` labels.
23+
* A set of :ref:`conventions <conventions-for-labels>` for normalizing and
24+
assigning semantics to ``Project-URL`` labels during consumer-side metadata
25+
processing.
2526

2627
Rationale and Motivation
2728
========================
@@ -35,21 +36,21 @@ for expressing a package's relationship to external resources, via URLs:
3536
1. Metadata 1.0 introduced ``Home-page``, a single-use field containing
3637
a URL to the distribution's home page.
3738

38-
.. code-block::
39+
.. code-block:: email
3940
4041
Home-page: https://example.com/sampleproject
4142
4243
2. Metadata 1.1 introduced ``Download-URL``, a complementary single-use field
4344
containing a URL suitable for downloading the current distribution.
4445

45-
.. code-block::
46+
.. code-block:: email
4647
4748
Download-URL: https://example.com/sampleproject/sampleproject-1.2.3.tar.gz
4849
4950
3. Metadata 1.2 introduced ``Project-URL``, a **multiple-use** field containing
5051
a label-and-URL pair. Each label is free text conveying the URL's semantics.
5152

52-
.. code-block::
53+
.. code-block:: email
5354
5455
Project-URL: Homepage, https://example.com/sampleproject
5556
Project-URL: Download, https://example.com/sampleproject/sampleproject-1.2.3.tar.gz
@@ -93,9 +94,6 @@ This PEP stipulates the following for metadata producers:
9394
* When generating metadata 1.2 or later, producers **SHOULD** emit only
9495
``Project-URL``, and **SHOULD NOT** emit ``Home-page`` or ``Download-URL``
9596
fields.
96-
* When generating ``Project-URL`` equivalents for ``Home-page`` and
97-
``Download-URL``, producers **SHOULD** use the
98-
:ref:`label conventions <conventions-for-labels>` described below.
9997

10098
These stipulations do not change the optionality of URL fields in core metadata.
10199
In other words, producers **MAY** choose to omit ``Project-URL`` entirely
@@ -106,6 +104,11 @@ or ``Download-URL``. However, see :ref:`future-considerations` for
106104
thoughts on how a new (as of yet unspecified) major core metadata version
107105
could complete the deprecation cycle via removal of these deprecated fields.
108106

107+
Similarly, this PEP does **not** propose that metadata producers emit
108+
:ref:`normalized labels <label-normalization>`. Label normalization is performed
109+
solely on the processing and consumption side (i.e. within indices and other
110+
consumers of distribution metadata).
111+
109112
.. _package-indices:
110113

111114
Package indices
@@ -153,10 +156,13 @@ informal relationship between ``Home-page``, ``Download-URL``, and their
153156

154157
This formalization has two parts:
155158

156-
1. A set of rules for normalizing ``Project-URL`` labels;
159+
1. A set of rules for normalizing ``Project-URL`` labels during index-side
160+
processing;
157161
2. A set of "well-known" normalized label values that indices may specialize
158162
URL presentation for.
159163

164+
.. _label-normalization:
165+
160166
Label normalization
161167
-------------------
162168

@@ -190,14 +196,22 @@ normalization:
190196
"``Change_Log``", "``changelog``"
191197
"``What's New?``", "``whatsnew``"
192198

193-
Metadata producers **SHOULD** emit the normalized form of a user
194-
specified label, but **MAY** choose to emit the un-normalized form so
195-
long as it adheres to the existing 32 character constraint.
199+
When processing distribution metadata, package indices **SHOULD** perform
200+
label normalization to determine if a given label is
201+
:ref:`well known <well-known>` for subsequent special processing.
202+
Labels that are not well-known **MUST** be processed in their un-normalized
203+
form.
204+
205+
Normalization does **not** change pre-existing semantics around duplicated
206+
``Project-URL`` labels. In other words, normalization may result in duplicate
207+
labels in the project's metadata, but only in the same manner that was already permitted
208+
(since the :ref:`core metadata specification <packaging:core-metadata>` does
209+
not stipulate that labels are unique).
196210

197-
Package indices **SHOULD NOT** use the normalized labels belonging to the set
198-
of well-known labels directly as UI elements (instead replacing them with
199-
appropriately capitalized text labels). Labels not belonging to the well-known
200-
set **MAY** be used directly as UI elements.
211+
Excerpted examples of normalized metadata fields are provided in
212+
:ref:`Appendix A <appendix-a>`.
213+
214+
.. _well-known:
201215

202216
Well-known labels
203217
-----------------
@@ -243,15 +257,9 @@ Indices **MAY** choose to use the human-readable equivalents suggested above
243257
in their UI elements, if appropriate. Alternatively, indices **MAY** choose
244258
their own appropriate human-readable equivalents for UI elements.
245259

246-
Packagers and metadata producers **MAY** choose to use these well-known
247-
labels or their aliases to communicate specific URL intents to package indices
248-
and downstreams.
249-
250-
Packagers and metadata producers **SHOULD** produce the normalized version
251-
of the well-known labels or their aliases in package metadata. Packaging tools
252-
**MUST NOT** transform between equivalent aliases, i.e.. **SHOULD**
253-
normalize ``GitHub`` to ``github`` but **MUST NOT** transform
254-
``github`` to ``source``.
260+
Packagers and metadata producers **MAY** choose to use any label that normalizes
261+
to these labels (or their aliases) to communicate specific URL intents to
262+
package indices and downstreams.
255263

256264
Similarly, indices **MAY** choose to specialize their rendering or presentation
257265
of URLs with these labels, e.g. by presenting an appropriate icon or tooltip
@@ -264,12 +272,9 @@ for documentation hosting or issue tracking).
264272

265273
This PEP recognizes that the list of well-known labels is unlikely to remain
266274
static, and that subsequent additions to it should not require the overhead
267-
associated with a formal PEP process or new metadata version. As the primary
268-
expected use case for this information is to control the way project URLs are
269-
displayed on the Python Package Index, this PEP proposes that the list above
270-
become a "living" list within PyPI's documentation (at time of writing, the
271-
documentation for influencing PyPI's URL display can be found
272-
`here <https://docs.pypi.org/project_metadata/#icons>`__).
275+
associated with a formal PEP process or new metadata version. As such,
276+
this PEP proposes that the list above become a "living" list within
277+
the :ref:`PyPA specifications <packaging:packaging-specifications>`.
273278

274279
Backwards Compatibility
275280
=======================
@@ -349,6 +354,44 @@ already contains an informal description of PyPI's URL handling behavior.
349354
If this PEP is accepted, the authors of this PEP will coordinate to update
350355
and cross-link the resources mentioned above.
351356

357+
.. _appendix-a:
358+
359+
Appendix A: Label normalization examples
360+
========================================
361+
362+
This appendix provides an illustrative excerpt of a distribution's
363+
metadata, before and after index-side processing:
364+
365+
Before:
366+
367+
.. code-block:: email
368+
369+
Project-URL: Home-page, https://example.com
370+
Project-URL: Homepage, https://another.example.com
371+
Project-URL: Source, https://github.com/example/example
372+
Project-URL: GitHub, https://github.com/example/example
373+
Project-URL: Another Service, https://custom.example.com
374+
375+
376+
After:
377+
378+
.. code-block:: email
379+
380+
Project-URL: homepage, https://example.com
381+
Project-URL: homepage, https://another.example.com
382+
Project-URL: source, https://github.com/example/example
383+
Project-URL: github, https://github.com/example/example
384+
Project-URL: Another Service, https://custom.example.com
385+
386+
In particular, observe:
387+
388+
* Normalized duplicates are preserved (both ``Home-page`` and ``Homepage``
389+
become ``homepage``);
390+
* ``Source`` and ``GitHub`` are both normalized into their respective forms,
391+
but ``github`` is **not** transformed into ``source``.
392+
* ``Another Service`` is **not** normalized, since its normal form
393+
(``anotherservice``) is not a :ref:`well-known label <well-known>`.
394+
352395
Copyright
353396
=========
354397

0 commit comments

Comments
 (0)