Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

dash/underscore on name of package uploaded on pypi

1,760 views
Skip to first unread message

ast

unread,
Feb 28, 2019, 11:09:31 AM2/28/19
to
Hello

I just uploaded a package on pypi, whose name is "arith_lib"

The strange thing is that on pypi the package is renamed "arith-lib"
The underscore is substitued with a dash

If we search for this package:

pip search arith

arith-lib (2.0.0) - A set of functions for miscellaneous arithmetic
(so a dash)

For installation both:

pip install -U arith_lib
pip install -U arith-lib

are working well

and in both case I got a directory with an underscore

C:\Program Files\Python36-32\Lib\site-packages

28/02/2019 16:57 <REP> arith_lib
28/02/2019 16:57 <REP> arith_lib-2.0.0.dist-info

What happens ?

Paul Moore

unread,
Feb 28, 2019, 2:19:03 PM2/28/19
to
On Thu, 28 Feb 2019 at 16:14, ast <no...@gmail.com> wrote:
>
> Hello
>
> I just uploaded a package on pypi, whose name is "arith_lib"
>
> The strange thing is that on pypi the package is renamed "arith-lib"
> The underscore is substitued with a dash

The version with a dash is the normalised form of the name - see
https://www.python.org/dev/peps/pep-0503/#normalized-names

Paul

Terry Reedy

unread,
Feb 28, 2019, 4:08:00 PM2/28/19
to
To expand on Paul's answer.

English uses '-' both as a connector for compound names and as a
subtraction operator. Context usually makes the choice obvious. But
context-free parsers must choose just one, and for computation,
subtraction wins. 'arith-lib' is parsed as (arith) - (lib). Many
algorithm languages use '_' instead of '-' as the compounder for
identifiers (object names).

In addition, Python uses filenames -(minus) '.py' as identifiers for
imported modules. So if the repository allows '-' in package names,
installers must convert '-' to '_'. But if the repository allows
'arith_lib' and 'arith-lib' to be distinct names for different packages,
both would be installed with the same file name. So the repository
standardizes on one form, and it went with English instead of Pythonese.

--
Terry Jan Reedy


Dmitry Labazkin

unread,
Jun 1, 2022, 4:00:10 PM6/1/22
to
Hi,

Recently I wrote the article about packages vs distributions and also explored naming and normalization:
https://labdmitriy.github.io/blog/distributions-vs-packages/#additional-experiments

In the section “Additional experiments” I got the expected normalization results, but in “Open questions” I found that for another package URL is not normalized and original URL is used, and name is partially normalized (underscore is replaced by hyphen but dot remains unchanged).

Could you please explain this behavior?

Thank you.
0 new messages