diff --git a/source/specifications/core-metadata.rst b/source/specifications/core-metadata.rst index b8cd5326e..6b5efd13a 100644 --- a/source/specifications/core-metadata.rst +++ b/source/specifications/core-metadata.rst @@ -73,15 +73,10 @@ Name .. versionadded:: 1.0 .. versionchanged:: 2.1 - Added additional restrictions on format from :pep:`508` + Added restrictions on format from the :ref:`name grammar `. The name of the distribution. The name field is the primary identifier for a -distribution. A valid name consists only of ASCII letters and numbers, period, -underscore and hyphen. It must start and end with a letter or number. -Distribution names are limited to those which match the following -regex (run with ``re.IGNORECASE``):: - - ^([A-Z0-9]|[A-Z0-9][A-Z0-9._-]*[A-Z0-9])$ +distribution. It must conform to the :ref:`package name grammar `. Example:: diff --git a/source/specifications/name-normalization.rst b/source/specifications/name-normalization.rst index 64be4a1d1..fb6d22a09 100644 --- a/source/specifications/name-normalization.rst +++ b/source/specifications/name-normalization.rst @@ -1,13 +1,16 @@ -.. _name-normalization: +====================================== +Package name grammar and normalization +====================================== + +Project names obey a restricted format, and are "normalized" for use in various +contexts. This document describes what the valid project names are, and how +project names should be normalized. -========================== -Package name normalization -========================== -Project names are "normalized" for use in various contexts. This document describes how project names should be normalized. +.. _name-grammar: -Valid non-normalized names --------------------------- +Name grammar +============ A valid name consists only of ASCII letters and numbers, period, underscore and hyphen. It must start and end with a letter or number. @@ -16,10 +19,15 @@ following regex (run with ``re.IGNORECASE``):: ^([A-Z0-9]|[A-Z0-9][A-Z0-9._-]*[A-Z0-9])$ -Normalization -------------- -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: +.. _name-normalization: + +Name normalization +================== + +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: .. code-block:: python @@ -30,7 +38,7 @@ The name should be lowercased with all runs of the characters ``.``, ``-``, or ` This means that the following names are all equivalent: -* ``friendly-bard`` (normalized form) +* ``friendly-bard`` (normalized form) * ``Friendly-Bard`` * ``FRIENDLY-BARD`` * ``friendly.bard``