Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pip -e: No magic underscore to dash replacement

Somewhere underscores get changed to dashes, if you install with a git repo with "pip install -e ...".

Is there any way to stop this?

I want to automate stuff. I want repo foo_bar to be ~/src/foo_bar, not ~/src/foo-bar.

like image 738
guettli Avatar asked Sep 30 '13 14:09

guettli


2 Answers

From what I can see from this question and this response on the Python mailing list it looks like this is due to numerous naming conventions throughout the Python packaging system, and the compatibility between them.

Pythons setuptools runs safe_name which:

Convert an arbitrary string to a standard distribution name

Any runs of non-alphanumeric/. characters are replaced with a single '-'.

Even though pip, easy_install and PyPi may accept the underscore, when installing it is changed to a single '-' for setuptools standards.

like image 80
Ewan Avatar answered Oct 20 '22 15:10

Ewan


Note that the answer above is incorrect. The exact regex from the code is re.sub('[^A-Za-z0-9.]+', '-', name). But if you try pip install foo!bar you get a big parse error so this isn't really true either.

like image 39
boxed Avatar answered Oct 20 '22 14:10

boxed