dash/underscore on name of package uploaded on pypi
Dmitry Labazkin
labdmitriy at gmail.com
Wed Jun 1 15:59:58 EDT 2022
On Friday, March 1, 2019 at 12:08:00 AM UTC+3, Terry Reedy wrote:
> On 2/28/2019 11:09 AM, ast 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
> >
> > 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 ?
> 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
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.
More information about the Python-list
mailing list