WIP: Fix/pep 625 setuptools
Patch pkg_resources.safe_name
in an attempt to fix the root cause of the inconsistency between setuptools' internal normalization and PEP 625's normalization.
PEP 625 states that sdist filenames must be normalized such that [.-] in project names are replaced by _ in the sdist filename, among other rules such as lowercasing every character.
Coincidentally, setuptools infers project names from the sdist filename, with the rule that characters not matching [A-Za-z0-9.] are replaced by -; in particular . maps to . and _ maps to - in the infered project name. This is done by pkg_resources.safe_name. After this the result is further lowercased to be used as a key for looking up distributions in a package index or already available in the filesystem environment.
In particular, PEP 625 maps [.-_] to the same character:
-
[.-_]
--(PEP 625)-->_
Thus, the round trip maps [.-_] like this:
-
[.-_]
--(PEP 625)-->_
--(safe_name)-->-
--(.lower)-->-
While safe_name + .lower map . and [-_] to different characters:
-
.
--(safe_name)-->.
--(.lower)-->.
-
[-_]
--(safe_name)-->-
--(.lower)-->-
This means project names containing . are stored internally under a key that is different to the key which is used for lookup - leading to such projects not being found in the package index and appear missing when they are already installed.