Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wheel spec: Update rules on escaping components of wheel filename #844

Merged
merged 1 commit into from
Feb 28, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions source/specifications/binary-distribution-format.rst
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,17 @@ package's basic interpreter requirements and are detailed in PEP 425.
Escaping and Unicode
''''''''''''''''''''

Each component of the filename is escaped by replacing runs of
non-alphanumeric characters with an underscore ``_``::

re.sub("[^\w\d.]+", "_", distribution, re.UNICODE)
As the components of the filename are separated by a dash (``-``, HYPHEN-MINUS),
this character cannot appear within any component. This is handled as follows:

- In distribution names, any run of ``-_.`` characters (HYPHEN-MINUS, LOW LINE
and FULL STOP) should be replaced with ``_`` (LOW LINE). This is equivalent
to :pep:`503` normalisation followed by replacing ``-`` with ``_``.
- Version numbers should be normalised according to :pep:`440`, and then ``-``
characters should be replaced with ``_`` (LOW LINE). Normalised version
numbers cannot contain ``_``, so the replacement does not lose information.
pfmoore marked this conversation as resolved.
Show resolved Hide resolved
- The remaining components may not contain ``-`` characters, so no escaping
is necessary.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I personally feel that we should require tools generating wheels to fail with an error if the above rules result in any component still containing a dash, just as a last-ditch safety measure to protect against future standards changes failing to take the wheel naming requirements into account, but no-one else seemed too interested in that, so I'll let it drop at this point.


The archive filename is Unicode. It will be some time before the tools
are updated to support non-ASCII filenames, but they are supported in
Expand Down Expand Up @@ -437,6 +444,14 @@ Is it possible to import Python code directly from a wheel file?
aware that many projects will require a failure to be reproduced with
a fully installed package before accepting it as a genuine bug.

Changes
=======

Since :pep:`427`, this specification has changed as follows:

- The rules on escaping in wheel filenames were revised, to bring them into line
with what popular tools actually do (February 2021).


References
==========
Expand Down