dash/underscore on name of package uploaded on pypi

Terry Reedy tjreedy at udel.edu
Thu Feb 28 16:07:36 EST 2019


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





More information about the Python-list mailing list