Skip to content

Commit c297892

Browse files
committed
Clarify .dist-info naming to match reality
The writeup about .dist-info naming rules did not match reality. Additional text is added to clarify that 1. Tools should replace dashes with underscores in the file name. 2. Existing tools do not follow PEP 503 normalization, so parsing tools should not expect this. 3. New tools are encouraged to perform PEP 503 normalization.
1 parent 079f4ec commit c297892

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

‎source/specifications/recording-installed-packages.rst‎

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,22 @@ Each project installed from a distribution must, in addition to files,
3838
install a "``.dist-info``" directory located alongside importable modules and
3939
packages (commonly, the ``site-packages`` directory).
4040

41-
This directory is named as ``{name}-{version}.dist-info``, with `name` and
42-
`version` fields corresponding to :ref:`core-metadata`.
43-
The name field must be in normalized form (see `PEP 503 <https://www.python.org/dev/peps/pep-0503/#normalized-names>`_
44-
for the definition of normalization).
41+
This directory is named as ``{name}-{version}.dist-info``, with ``name`` and
42+
``version`` fields corresponding to :ref:`core-metadata`. Both fields must be
43+
normalized (see :pep:`PEP 503 <503#normalized-names>` and
44+
:pep:`PEP 440 <440#normalization>` for the definition of normalization for
45+
each field respectively), and replace dash (``-``) characters with
46+
underscore (``_``) chacaters, so the ``.dist-info`` directory always has
47+
exactly one dash (``-``) character in its stem, separating the ``name`` and
48+
``version`` fields.
49+
50+
Historically, tools have failed to replace dot characters or normalize case in
51+
the ``name`` field, or not perform normalization in the ``version`` field.
52+
Tools consuming ``.dist-info`` directories should expect those fields to be
53+
unnormalized, and treat them as equivalent to their normalized counterparts.
54+
New tools that write ``.dist-info`` directories MUST normalize both ``name``
55+
and ``version`` fields using the rules described above, and existing tools are
56+
encouraged to start normalizing those fields.
4557

4658
This ``.dist-info`` directory can contain these files, described in detail
4759
below:

0 commit comments

Comments
 (0)