Escaping versions for wheel, sdist, and .dist-info names

I just realised that there wasn’t much discussion here of what to do with distribution names, even though we ended up changing the rules there. @uranusjr was in favour of adopting the name normalisation from PEP 503, @pf_moore said “We should clean this up, but it’s not going to happen in this change”… and then the rule based on PEP 503 seems to have slipped in, while we were all focusing on the version part and where the spec lives. :confused:

This has come up because Flit has now implemented the updated spec - where . is translated to _ in the distribution name part of the .whl filename - and clashed with the rules implemented in Warehouse, which don’t allow that.

On the one hand, I think the new version is a clearly better spec in isolation. It gives us one rule for wheel filenames, sdist filenames and .dist-info directory names, and it means you can construct a wheel filename from a (PEP 503) normalised project name or an un-normalised project name and get the same result. On the other hand, it’s not what setuptools/wheel & warehouse currently do.

The change to the spec was merged on the 28th of February, so it’s been there for 9 months. Do we press forward and adapt the software to the spec? Or do we revert that part of the change as a mistake?

For extra complexity, the original spec is kind of ambiguous: the words say you replace “non-alphanumeric characters” with an underscore, which IMO would mean replacing . (".".isalnum() is False). But the code sample that accompanies it specifically exempts . from the regex-based replacement. I imagine we take the code sample as the definitive rule, so this is probably academic.