. and _ in Python package names get replaced with - #10173

Closed
opened 2025-11-02 09:00:14 -06:00 by GiteaMirror · 2 comments
Owner

Originally created by @rijenkii on GitHub (Jan 28, 2023).

Description

After uploading a package with a name company.package_name to Gitea, resulting package saves under the name company-package-name.

I do not think that this is correct behavior, because pypi.org hosts packages with names such as zope.interface and 0-._.-._.-._.-._.-._.-._.-0.

Repro on try.gitea.io: https://try.gitea.io/rijenkii/-/packages/pypi/company-project-name/1.0.0

Gitea Version

1.19.0+dev-364-ge9cd18b55

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

No response

How are you running Gitea?

try.gitea.io

Database

No response

Originally created by @rijenkii on GitHub (Jan 28, 2023). ### Description After uploading a package with a name `company.package_name` to Gitea, resulting package saves under the name `company-package-name`. I do not think that this is correct behavior, because pypi.org hosts packages with names such as [`zope.interface`](https://pypi.org/project/zope.interface) and [`0-._.-._.-._.-._.-._.-._.-0`](https://pypi.org/project/0-._.-._.-._.-._.-._.-._.-0/). Repro on try.gitea.io: https://try.gitea.io/rijenkii/-/packages/pypi/company-project-name/1.0.0 ### Gitea Version 1.19.0+dev-364-ge9cd18b55 ### Can you reproduce the bug on the Gitea demo site? Yes ### Log Gist _No response_ ### Screenshots _No response_ ### Git Version _No response_ ### Operating System _No response_ ### How are you running Gitea? try.gitea.io ### Database _No response_
GiteaMirror added the type/bugissue/not-a-bug labels 2025-11-02 09:00:14 -06:00
Author
Owner

@rijenkii commented on GitHub (Jan 28, 2023):

It seems that these characters are implicitly replaced with -:
e9cd18b557/routers/api/packages/pypi/pypi.go (L25)

Question is: god, why

@rijenkii commented on GitHub (Jan 28, 2023): It seems that these characters are implicitly replaced with `-`: https://github.com/go-gitea/gitea/blob/e9cd18b5578cdf84264f3d69a5f166a33d74b4e3/routers/api/packages/pypi/pypi.go#L25 Question is: *god, why*
Author
Owner

@rijenkii commented on GitHub (Jan 28, 2023):

I found the why:

https://peps.python.org/pep-0503/#normalized-names.

As per PEP 426 the only valid characters in a name are the ASCII alphabet, ASCII numbers, ., -, and _. The name should be lowercased with all runs of the characters ., -, or _ replaced with a single - character.

https://peps.python.org/pep-0426/#name

All comparisons of distribution names MUST be case insensitive, and MUST consider hyphens and underscores to be equivalent.

So, not a bug.

@rijenkii commented on GitHub (Jan 28, 2023): I found the why: https://peps.python.org/pep-0503/#normalized-names. > As per [PEP 426](https://peps.python.org/pep-0426) the only valid characters in a name are the ASCII alphabet, ASCII numbers, ., -, and _. The name should be lowercased with all runs of the characters ., -, or _ replaced with a single - character. https://peps.python.org/pep-0426/#name > All comparisons of distribution names MUST be case insensitive, and MUST consider hyphens and underscores to be equivalent. So, not a bug.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#10173