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

pdm-backend should not normalize names in project metadata #185

Closed
warsaw opened this issue Jun 22, 2023 · 10 comments · Fixed by #186
Closed

pdm-backend should not normalize names in project metadata #185

warsaw opened this issue Jun 22, 2023 · 10 comments · Fixed by #186
Assignees

Comments

@warsaw
Copy link

warsaw commented Jun 22, 2023

In the long thread on discuss.python.org several problems related to normalization of package names have been identified. Specifically, pdm-backend's behavior of normalizing the package name in the project metadata causes PyPI to incorrectly display the package's intentional name and pip install instructions.

Context is contained in the thread linked above.

FWIW, I actually don't care about the file names - normalize away! I just want the metadata project name to match what I put in pyproject.toml!

@frostming
Copy link
Contributor

It is the behavior of pyproject-metadata, can you report the issue there?

@warsaw
Copy link
Author

warsaw commented Jun 25, 2023

@frostming frostming self-assigned this Jun 26, 2023
frostming added a commit that referenced this issue Jun 26, 2023
Fixes #185

Signed-off-by: Frost Ming <me@frostming.com>
@warsaw
Copy link
Author

warsaw commented Jun 26, 2023

Thank you! I've confirmed this fixes the problem in the metadata. Unfortunately, the project name is still getting normalized on PyPI, so I will follow up over there.

@warsaw
Copy link
Author

warsaw commented Jun 26, 2023

This is not solved: pypi/warehouse#13992 (comment)

But I think this is a bug in pdm front-end, not pdm-backend. @frostming what do you think? Should I report it over there?

@frostming
Copy link
Contributor

frostming commented Jun 27, 2023

But twine is doing the same: https://github.com/pypa/twine/blob/0bb428c410b8df64c04dc881ac1db37d932f3066/twine/package.py#L146

Maybe only flit doesn't normalize it?

@frostming
Copy link
Contributor

frostming commented Jun 27, 2023

Okay, hatch doesn't normalize either, I will change it in PDM.

@warsaw
Copy link
Author

warsaw commented Jun 27, 2023

I think both twine and flit do the right thing. I had a long discussion with @dstufft about this, and he gave me a little bit of Python code to test what those tools do when uploading to PyPI). Here's what I've seen:

PDM:

FieldStorage('name', None, 'flufl-enum')
127.0.0.1 - - [26/Jun/2023 13:51:49] "POST / HTTP/1.1" 200 0
FieldStorage('name', None, 'flufl-enum')
127.0.0.1 - - [26/Jun/2023 13:51:49] "POST / HTTP/1.1" 200 0

flit:

FieldStorage('name', None, 'flufl.enum')
127.0.0.1 - - [26/Jun/2023 13:55:12] "POST / HTTP/1.1" 200 0
FieldStorage('name', None, 'flufl.enum')
127.0.0.1 - - [26/Jun/2023 13:55:21] "POST / HTTP/1.1" 200 0

twine:

FieldStorage('name', None, 'flufl.enum')
127.0.0.1 - - [26/Jun/2023 13:58:34] "POST / HTTP/1.1" 200 0
FieldStorage('name', None, 'flufl.enum')
127.0.0.1 - - [26/Jun/2023 13:58:34] "POST / HTTP/1.1" 200 0

So you can see that only PDM is sending flufl-enum while both twine and flit send flufl.enum. @dstufft told me that this is the only information PyPI uses to set the visible name and pip install instructions on a package's home page. Although in the future it might read the package's metadata for this, currently the upload name is what's used.

You can see the effects of this very clearly at: https://pypi.org/project/flufl-enum/

(I'm not sure if the canonical URL is also taken from that, but I care a little less about that because https://pypi.org/project/flufl.enum/ does redirect.)

@warsaw
Copy link
Author

warsaw commented Jun 27, 2023

Okay, hatch doesn't normalize either, I will change it in PDM.

Thanks! Is there an issue over in PDM I can follow?

@frostming
Copy link
Contributor

Thanks! Is there an issue over in PDM I can follow?

pdm-project/pdm#2057

@warsaw
Copy link
Author

warsaw commented Jun 27, 2023

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants