diff --git a/pep-0685.rst b/pep-0685.rst index 41d0d1fe2..020aa33a8 100644 --- a/pep-0685.rst +++ b/pep-0685.rst @@ -7,7 +7,7 @@ Status: Draft Type: Standards Track Content-Type: text/x-rst Created: 08-Mar-2022 -Post-History: 08-Mar-2022 +Post-History: `08-Mar-2022 `__ Abstract @@ -28,13 +28,13 @@ name "must be a valid Python identifier". letter, digit, or any one of ``.``, ``-``, or ``_`` after the initial character. Otherwise, there is no other `PyPA specification `_ -which outlines how extra names should be written or normalization for comparison. +which outlines how extra names should be written or normalized for comparison. Due to the amount of packaging-related code in existence, it is important to evaluate current practices by the community and -standardize on one that doesn't break most code, while being +standardize on one that doesn't break most existing code, while being something tool authors can agree to following. -The issue of there being no standard was brought forward by an +The issue of there being no consistent standard was brought forward by an `initial discussion `__ noting that the extra ``adhoc-ssl`` was not considered equal to the name ``adhoc_ssl`` by pip 22. @@ -47,27 +47,29 @@ Rationale re.sub(r"[-_.]+", "-", name).lower() -This collapses any run of the substitution character down to a single -character, -e.g. ``---`` gets collapsed down to ``-``. -This does **not** produce a valid Python identifier as specified by +This collapses any run of the characters ``-``, ``_`` and ``.`` +down to a single ``-``. +For example, ``---`` ``.`` and ``__`` all get converted to just ``-``. +This does **not** produce a valid Python identifier, per the core metadata 2.2 specification for extra names. -`Setuptools 60 does normalization `__ +`Setuptools 60 performs normalization `__ via:: re.sub(r'[^A-Za-z0-9-.]+', '_', name).lower() -The use of an underscore/``_`` differs from PEP 503's use of a -hyphen/``-``. -Runs of ``.`` and ``-``, unlike PEP 503, do **not** get collapsed, -e.g. ``..`` stays the same. +The use of an underscore/``_`` differs from PEP 503's use of a hyphen/``-``, +and it also normalizes characters outside of those allowed by :pep`508`. +Runs of ``.`` and ``-``, unlike PEP 503, do **not** get normalized to one ``_``, +e.g. ``..`` stays the same. To note, this is inconsistent with this function's +docstring, which *does* specify that all non-alphanumeric characters +(which would include ``-`` and ``.``) are normalized and collapsed. For pip 22, its -"extra normalisation behaviour is quite convoluted and erratic" [pip-erratic]_, +"extra normalisation behaviour is quite convoluted and erratic" [pip-erratic]_ and so its use is not considered. -.. [pip-erratic] https://discuss.python.org/t/what-extras-names-are-treated-as-equal-and-why/7614/10? +.. [pip-erratic] Tzu-ping Chung on Python Discourse