JoshData / python-email-validator

A robust email syntax and deliverability validation library for Python.
The Unlicense
1.14k stars 112 forks source link

Installed package name should use dash not underscore #138

Closed quassy closed 4 months ago

quassy commented 6 months ago

According to PEP 503 package names should only use ASCII alphanumeric and - (dash), all other characters should be replaced with - (dash).

After installing email-validator (correct name in PyPI), the name for the installed package given by pip list is email_validator.

~I think just the name in setup.cfg has to be changed to email-validator.~ (The import would of course still be email_validator.)

JoshData commented 6 months ago

PEP 503 is not relevant to packaging. It links to PEP 426 whose status is Withdrawn.

I'm not a packaging expert so I have to go by what I read, but these links don't back up your point.

quassy commented 6 months ago

You are right, 503 only mentions the “project name”. But I guess that project name is used for the package name and 503 is also mentioned by the packaging guide. Not sure how “official” that is.

Generally it seems that PyPI and tools like PIP handle dash/underscore as the same character and seem to prefer dash (PyPI redirects email_validator to email-validator).

The reason I stumbled upon this is that PyCharm will not detect a requirement email-validator as being installed because it's installed as email_validator, but maybe there is another underlying reason for this / it's a PyCharm issue then.

JoshData commented 6 months ago

Since pip can figure it out, I think it's a PyCharm issue. Maybe I should change it to be consistent, but I want to be careful not to break things for existing users until a major version change.

jirikuncar commented 6 months ago

It is more of a general consistency issue. I noticed a change in our lock file when updating FastAPI. Until recently, the resolved name was the normalized email-validator, which has changed to email_validator. Since PyPI is redirecting to the dash version, I would suggest changing the package name in metadata to the normalized version. I would not blame only PyCharm, but there can be other tools that might not be able to handle the non-normalized package name in metadata.