@@ -155,10 +155,17 @@ package's basic interpreter requirements and are detailed in PEP 425.
155155Escaping and Unicode
156156''''''''''''''''''''
157157
158- Each component of the filename is escaped by replacing runs of
159- non-alphanumeric characters with an underscore ``_ ``::
160-
161- re.sub("[^\w\d.]+", "_", distribution, re.UNICODE)
158+ As the components of the filename are separated by a dash (``- ``, HYPHEN-MINUS),
159+ this character cannot appear within any component. This is handled as follows:
160+
161+ - In distribution names, any run of ``-_. `` characters (HYPHEN-MINUS, LOW LINE
162+ and FULL STOP) should be replaced with ``_ `` (LOW LINE). This is equivalent
163+ to :pep: `503 ` normalisation followed by replacing ``- `` with ``_ ``.
164+ - Version numbers should be normalised according to :pep: `440 `, and then ``- ``
165+ characters should be replaced with ``_ `` (LOW LINE). Normalised version
166+ numbers cannot contain ``_ ``, so the replacement does not lose information.
167+ - The remaining components may not contain ``- `` characters, so no escaping
168+ is necessary.
162169
163170The archive filename is Unicode. It will be some time before the tools
164171are updated to support non-ASCII filenames, but they are supported in
@@ -437,6 +444,14 @@ Is it possible to import Python code directly from a wheel file?
437444 aware that many projects will require a failure to be reproduced with
438445 a fully installed package before accepting it as a genuine bug.
439446
447+ Changes
448+ =======
449+
450+ Since :pep: `427 `, this specification has changed as follows:
451+
452+ - The rules on escaping in wheel filenames were revised, to bring them into line
453+ with what popular tools actually do (February 2021).
454+
440455
441456References
442457==========
0 commit comments