@@ -15,13 +15,14 @@ Post-History: `26-Aug-2024 <https://discuss.python.org/t/core-metadata-should-ho
15
15
Abstract
16
16
========
17
17
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 :
20
20
21
21
* Deprecation of the ``Home-page `` and ``Download-URL `` fields in favor of
22
22
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.
25
26
26
27
Rationale and Motivation
27
28
========================
@@ -35,21 +36,21 @@ for expressing a package's relationship to external resources, via URLs:
35
36
1. Metadata 1.0 introduced ``Home-page ``, a single-use field containing
36
37
a URL to the distribution's home page.
37
38
38
- .. code-block ::
39
+ .. code-block :: email
39
40
40
41
Home-page: https://example.com/sampleproject
41
42
42
43
2. Metadata 1.1 introduced ``Download-URL ``, a complementary single-use field
43
44
containing a URL suitable for downloading the current distribution.
44
45
45
- .. code-block ::
46
+ .. code-block :: email
46
47
47
48
Download-URL: https://example.com/sampleproject/sampleproject-1.2.3.tar.gz
48
49
49
50
3. Metadata 1.2 introduced ``Project-URL ``, a **multiple-use ** field containing
50
51
a label-and-URL pair. Each label is free text conveying the URL's semantics.
51
52
52
- .. code-block ::
53
+ .. code-block :: email
53
54
54
55
Project-URL: Homepage, https://example.com/sampleproject
55
56
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:
93
94
* When generating metadata 1.2 or later, producers **SHOULD ** emit only
94
95
``Project-URL ``, and **SHOULD NOT ** emit ``Home-page `` or ``Download-URL ``
95
96
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.
99
97
100
98
These stipulations do not change the optionality of URL fields in core metadata.
101
99
In other words, producers **MAY ** choose to omit ``Project-URL `` entirely
@@ -106,6 +104,11 @@ or ``Download-URL``. However, see :ref:`future-considerations` for
106
104
thoughts on how a new (as of yet unspecified) major core metadata version
107
105
could complete the deprecation cycle via removal of these deprecated fields.
108
106
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
+
109
112
.. _package-indices :
110
113
111
114
Package indices
@@ -153,10 +156,13 @@ informal relationship between ``Home-page``, ``Download-URL``, and their
153
156
154
157
This formalization has two parts:
155
158
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;
157
161
2. A set of "well-known" normalized label values that indices may specialize
158
162
URL presentation for.
159
163
164
+ .. _label-normalization :
165
+
160
166
Label normalization
161
167
-------------------
162
168
@@ -190,14 +196,22 @@ normalization:
190
196
"``Change_Log ``", "``changelog ``"
191
197
"``What's New? ``", "``whatsnew ``"
192
198
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).
196
210
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 :
201
215
202
216
Well-known labels
203
217
-----------------
@@ -243,15 +257,9 @@ Indices **MAY** choose to use the human-readable equivalents suggested above
243
257
in their UI elements, if appropriate. Alternatively, indices **MAY ** choose
244
258
their own appropriate human-readable equivalents for UI elements.
245
259
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.
255
263
256
264
Similarly, indices **MAY ** choose to specialize their rendering or presentation
257
265
of URLs with these labels, e.g. by presenting an appropriate icon or tooltip
@@ -264,12 +272,9 @@ for documentation hosting or issue tracking).
264
272
265
273
This PEP recognizes that the list of well-known labels is unlikely to remain
266
274
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 >`.
273
278
274
279
Backwards Compatibility
275
280
=======================
@@ -349,6 +354,44 @@ already contains an informal description of PyPI's URL handling behavior.
349
354
If this PEP is accepted, the authors of this PEP will coordinate to update
350
355
and cross-link the resources mentioned above.
351
356
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
+
352
395
Copyright
353
396
=========
354
397
0 commit comments