I recently received a bundle of Python code, written by a graduate student at an academic lab, and consisting of a Python script and about half dozen single-file Python modules, used by by the script. All these files (script and modules) are on the same directory.
I wanted to use pip
to install this code in a virtual environment, so I tried my hand at writing a setup.py
file for it, something I had not done before.
I got this installation to work, and I have a vague understanding of what most of the stuff I put in the setup.py
means.
The one exception to this is the value to the name
keyword to the setuptools.setup
function.
According to the documentation I found, this parameter is supposed to be the "name of the package", but I this doesn't tell me how its value ultimately matters. In other words, is this value important only to human readers, or does it actually affect either the way pip install
, or the code this command installs, will work?
Therefore, I had no idea what value to give to this parameter, and so I just came up with a reasonably-sounding name, but without any attempt to have it match something else in the code base. To my surprise, nothing broke! By this I mean that the pip
installation completed without errors, and the installed code performed correctly in the virtual environment.
I experimented a bit, and it seems that pretty much any value I came up was equally OK.
For the sake of the following description, suppose I give the name
parameter the value whatever
. Then, the only effect this has, as far as I can tell, is that a subdirectory with the name whatever.egg-info/
gets created (by pip
?) in the same directory as the setup.py
file, and this subdirectory contains two files that include the string whatever
in them.
One of these files is whatever.egg-info/PKG-INFO
, which contains the line
Name: whatever
The other one is whatever.egg-info/SOURCES.txt
, which lists several relative paths, including some beginning with whatever.egg-info/
.
Maybe this was too simple a packaging problem for the value of name
to matter?
Q: Can someone give me a simple example in which a wrong value for setuptools.setup
's name
parameter would cause either pip install
or the installed code to fail?