Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PyPI does not honor package name from author in some cases #13992

Closed
warsaw opened this issue Jun 22, 2023 · 15 comments
Closed

PyPI does not honor package name from author in some cases #13992

warsaw opened this issue Jun 22, 2023 · 15 comments
Labels
bug 🐛 requires triaging maintainers need to do initial inspection of issue

Comments

@warsaw
Copy link
Contributor

warsaw commented Jun 22, 2023

Describe the bug
PyPI's UI does not honor the package name I specify in my pyproject.toml file. This leads to confusion and incorrect (or at least unintentional) installation instructions on the PyPI front page of the project.

Take for example flufl.i18n. I clearly call the project that in its pyproject.toml file. That's the name I want to advertise the package as, and this intentional -- and legal -- so PyPI should honor that, even if the packaging tools normalize the upload file name. But this doesn't happen, as this screenshot illustrates.

Screenshot 2023-06-22 at 09 10 41

The URL is also normalized: https://pypi.org/project/flufl-i18n/.

Expected behavior
I would expect PyPI at least to display flufl.i18n 5.0.1 on the project page, and provide a pip install command as pip install flufl.i18n. If it doesn't do this, it directly conflicts with my intentional choices and my own documentation.

I think the URL should also be non-normalized, but I'm a little less concerned about that.

To Reproduce
Create a project with a dot in its name. Use a modern packaging tool that support pyproject.toml (flufl,i18n uses PDM). Upload that package to PyPI.

My Platform
n/a

Additional context
This may be related to the meta issue #12316 but I didn't see this specific issue discussed there (I could have missed it). It's also related to this discuss.python.org thread. It's probably also related to the root cause for a downstream bug report in GNU Mailman.

@warsaw warsaw added bug 🐛 requires triaging maintainers need to do initial inspection of issue labels Jun 22, 2023
@di
Copy link
Member

di commented Jun 22, 2023

PyPI respects the Name field in the project metadata of the artifact it was provided. In this case, it was flufl-i18n.

This was set by the build backend you were using, which consumed it from pyproject.toml before producing your distributions. If the value in your pyproject.toml and the value in your distributions metadata don't agree, that's a bug in your build backend, not with PyPI, as PyPI is not aware of pyproject.toml at all.

@di
Copy link
Member

di commented Jun 22, 2023

(And to be clear, if the Name value was flufl.i18n, PyPI would respect that, both in the web UI and URL. See https://pypi.org/project/jaraco.develop/7.22.1/ for a recent example)

@dstufft
Copy link
Member

dstufft commented Jun 22, 2023

Note that PyPI will rename the project to whatever the most recently uploaded artifact's Name field is. So this will be remediated upon your next release with a backend that doesn't normalize the name.

@warsaw
Copy link
Contributor Author

warsaw commented Jun 22, 2023

Thanks @di - that's what I suspected. In this case I'm using PDM and pdm-backend. I bet build backends are stuck between a rock and a hard place here, as evidenced by the discuss.python.org meta thread. I want to at least capture the issue so we can begin to unwind and fix the ecosystem.

@di
Copy link
Member

di commented Jun 22, 2023

@warsaw I agree with your intent, but I don't think there's anything actionable for PyPI to do here.

Given that PEP 621 says this about the name field:

Tools SHOULD normalize this name, as specified by PEP 503, as soon as it is read for internal consistency.

I think if you disagree with this behavior in build backeds, you probably need to take it up as an ecosystem-wide issue instead (which you kind of already have in your discourse thread).

@dstufft
Copy link
Member

dstufft commented Jun 22, 2023

The PEP that I hope to post this weekend clarifies that section of PEP 621, because I think that segment goes against what most people expected.

@warsaw
Copy link
Contributor Author

warsaw commented Jun 22, 2023

@dstufft 💯

Thank you!

@di
Copy link
Member

di commented Jun 23, 2023

@warsaw Given that a future PEP would likely resolve this, and that PyPI would likely not need to make changes as a result of that PEP, is it OK with you if we close this?

@warsaw
Copy link
Contributor Author

warsaw commented Jun 23, 2023

Yep, and thanks @di!

@warsaw warsaw closed this as completed Jun 23, 2023
@warsaw
Copy link
Contributor Author

warsaw commented Jun 26, 2023

@di I'm reopening this issue because I think there may still be a problem on the PyPI side. pdm-backend has been fixed to no longer normalize the package name metadata, but PyPI is still displaying the normalized name and pip install instructions.

Let's look at flufl.enum 6.0.1.

.whl METADATA excerpt:

Metadata-Version: 2.1
Name: flufl.enum
Version: 6.0.1
Summary: A Python enumeration package
Keywords: enum

sdist PKG-INFO excerpt:

Metadata-Version: 2.1
Name: flufl.enum
Version: 6.0.1
Summary: A Python enumeration package
Keywords: enum

Both metadata files are non-normalized, as we all now expect and want.

However, look at the PyPI page.

Screenshot 2023-06-26 at 10 15 32

It is still displaying the normalized name and instructions. I've verified the metadata by actually downloading the .whl and .tar.gz so I know that PyPI has the right information. But it's still displaying the wrong data.

@warsaw warsaw reopened this Jun 26, 2023
@dstufft
Copy link
Member

dstufft commented Jun 26, 2023

What is doing the upload? Because PyPI also doesn't read the METADATA file itself, whatever is doing the upload does that and sends it alongside the file as data.

@ewdurbin
Copy link
Member

ewdurbin commented Jun 26, 2023

@ewdurbin
Copy link
Member

Closing, PyPI is behaving as described.

@warsaw
Copy link
Contributor Author

warsaw commented Jun 26, 2023

Okay, thanks!

What is doing the upload? Because PyPI also doesn't read the METADATA file itself, whatever is doing the upload does that and sends it alongside the file as data.

TIL! I'm using pdm publish, so I think that's probably a bug in the PDM front-end. Maybe I can try flit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 requires triaging maintainers need to do initial inspection of issue
Projects
None yet
Development

No branches or pull requests

4 participants