Skip to content

Commit c62b169

Browse files
authored
Merge pull request #781 from uranusjr/dist-info-clarification
2 parents 68ad77c + 53985a5 commit c62b169

1 file changed

Lines changed: 27 additions & 4 deletions

File tree

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

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,33 @@ 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.
57+
58+
.. note::
59+
60+
The ``.dist-info`` directory's name is formatted to unambigiously represent
61+
a distribution as a filesystem path. Tools presenting a distribution name
62+
to a user should avoid using the normalized name, and instead present the
63+
specified name (when needed prior to resolution to an installed package),
64+
or read the respective fields in Core Metadata, since values listed there
65+
are unescaped and accurately reflect the distribution. Libraries should
66+
provide API for such tools to consume, so tools can have access to the
67+
unnormalized name when displaying distrubution information.
4568

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

0 commit comments

Comments
 (0)