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

Underscores in package name are converted to hyphens in distribution name while underscore is allowed character according to PEP 508 #920

Open
navrkald opened this issue Aug 16, 2022 · 0 comments · May be fixed by #921

Comments

@navrkald
Copy link

Your Environment

  1. Your operating system:
    Mac

  2. Version of python you are running:

Python 3.7.13

  1. How did you install twine? Did you use your operating system's package manager or pip or something else?

pipenv

  1. Version of twine you have installed:

1.8.3, requests: 2.28.1, requests-toolbelt: 0.9.1, urllib3: 1.26.11)

  1. Which package repository are you targeting?

Private package to private Artifactory.

The Issue

Underscores _ in package name are converted to hyphens - in generated distribution name.

So e.g. for package my_package is created distribution name my-package.

According to pep-508 underscore is considered as safe character so it shouldn't be converted to hyphens.

Distribution names should match following pattern:

^([A-Z0-9]|[A-Z0-9][A-Z0-9._-]*[A-Z0-9])$

As well mentioned in setup tools documentation

This is the name of your project, determining how your project is listed on PyPI. Per PEP 508, valid project names must:

Consist only of ASCII letters, digits, underscores (_), hyphens (-), and/or periods (.), and

Start & end with an ASCII letter or digit.

Comparison of project names is case insensitive and treats arbitrarily-long runs of underscores, hyphens, and/or periods as equal. For example, if you register a project named cool-stuff, users will be able to download it or declare a dependency on it using any of the following spellings:

This behaviour is causing problems e.g. if you have defined in Artifactory mandatory distribution name prefix containing underscores. E.g. org_name_prefix. So if you have package named org_name_prefix_my_package it is converted by twine to distribution name org-name-prefix-my-package and then Artifactory refuses to publish such package.

Only workaround I have found is to use old way of having setup.py and using command like this setup.py sdist upload -r local which doesn't convert underscores to hyphens in distribution name.

Steps to Reproduce

Create package with name containing underscores and distribution name of the package will have converted underscores to hyphens.

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.

1 participant