Looking at a random selection of well-known Python packages, why is there a general trend to not include a #!/usr/bin/env python
line at the top of setup.py
? I know that the usual recommended way of interacting with the file is something like:
python setup.py install
rather than
./setup.py install
but is there a good reason for this?
These packages do not include a shebang: pytest, lxml, six, virtualenv, pip
But these do: requests, simplejson, setuptools
The shebang line in any script determines the script's ability to be executed like a standalone executable without typing python beforehand in the terminal or when double clicking it in a file manager (when configured properly).
The shebang line was invented because scripts are not compiled, so they are not executable files, but people still want to "run" them. The shebang line specifies exactly how to run a script.
The setup.py file may be the most significant file that should be placed at the root of the Python project directory. It primarily serves two purposes: It includes choices and metadata about the program, such as the package name, version, author, license, minimal dependencies, entry points, data files, and so on.
The shebang character sequence is a special character sequence in a script file denoted by #! . It helps in specifying the type of program that should be called to run the entire script file. The shebang character sequence is always used in the first line of any file.
setup.py
is going to do the installation for the Python interpreter you are running it with and its library path. A shebang would define that interpreter and that is not desired by the developer.
Even if you have a setup.py
with a shebang, you should still run the file with the interpreter before it. It prevents you from questions like "Where the hack is the package gone!?"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With