Skip to content

Commit 045d09a

Browse files
authored
Merge pull request #1463 from jeanas/valid-names
Deduplicate specification of valid package names
2 parents 9cd20c6 + 1ca542e commit 045d09a

File tree

2 files changed

+22
-18
lines changed

2 files changed

+22
-18
lines changed

source/specifications/core-metadata.rst

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,11 @@ 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 format <name-format>`.
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:`name format specification
80+
<name-format>`.
8581

8682
Example::
8783

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+
Names and normalization
3+
=======================
4+
5+
This specification defines the format that names for packages and extras are
6+
required to follow. It also describes how to normalize them, which should be
7+
done before lookups and comparisons.
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-format:
811

9-
Valid non-normalized names
10-
--------------------------
12+
Name format
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)