Skip to content

Commit 3a90a88

Browse files
committed
Deduplicate specification of valid package names
- Rename the "Package name normalization" specification into "Package name grammar and normalization", to make it explicitly about the format of valid names too. - Link to this spec in the core metadata specification instead of duplicating the part about valid names.
1 parent 83fc010 commit 3a90a88

File tree

2 files changed

+21
-18
lines changed

2 files changed

+21
-18
lines changed

source/specifications/core-metadata.rst

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,10 @@ Name
7373

7474
.. versionadded:: 1.0
7575
.. versionchanged:: 2.1
76-
Added additional restrictions on format from :pep:`508`
76+
Added restrictions on format from the :ref:`name grammar <name-grammar>`.
7777

7878
The name of the distribution. The name field is the primary identifier for a
79-
distribution. A valid name consists only of ASCII letters and numbers, period,
80-
underscore and hyphen. It must start and end with a letter or number.
81-
Distribution names are limited to those which match the following
82-
regex (run with ``re.IGNORECASE``)::
83-
84-
^([A-Z0-9]|[A-Z0-9][A-Z0-9._-]*[A-Z0-9])$
79+
distribution. It must conform to the :ref:`package name grammar <name-grammar>`.
8580

8681
Example::
8782

source/specifications/name-normalization.rst

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1-
.. _name-normalization:
1+
======================================
2+
Package name grammar and normalization
3+
======================================
4+
5+
Project names obey a restricted format, and are "normalized" for use in various
6+
contexts. This document describes what the valid project names are, and how
7+
project names should be normalized.
28

3-
==========================
4-
Package name normalization
5-
==========================
69

7-
Project names are "normalized" for use in various contexts. This document describes how project names should be normalized.
10+
.. _name-grammar:
811

9-
Valid non-normalized names
10-
--------------------------
12+
Name grammar
13+
============
1114

1215
A valid name consists only of ASCII letters and numbers, period,
1316
underscore and hyphen. It must start and end with a letter or number.
@@ -16,10 +19,15 @@ following regex (run with ``re.IGNORECASE``)::
1619

1720
^([A-Z0-9]|[A-Z0-9][A-Z0-9._-]*[A-Z0-9])$
1821

19-
Normalization
20-
-------------
2122

22-
The name should be lowercased with all runs of the characters ``.``, ``-``, or ``_`` replaced with a single ``-`` character. This can be implemented in Python with the re module:
23+
.. _name-normalization:
24+
25+
Name normalization
26+
==================
27+
28+
The name should be lowercased with all runs of the characters ``.``, ``-``, or
29+
``_`` replaced with a single ``-`` character. This can be implemented in Python
30+
with the re module:
2331

2432
.. code-block:: python
2533
@@ -30,7 +38,7 @@ The name should be lowercased with all runs of the characters ``.``, ``-``, or `
3038
3139
This means that the following names are all equivalent:
3240

33-
* ``friendly-bard`` (normalized form)
41+
* ``friendly-bard`` (normalized form)
3442
* ``Friendly-Bard``
3543
* ``FRIENDLY-BARD``
3644
* ``friendly.bard``

0 commit comments

Comments
 (0)