Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does setup.py usually not have a shebang line?

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

like image 464
Milliams Avatar asked Feb 29 '16 13:02

Milliams


People also ask

Do you need shebang for Python script?

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).

What is the purpose of using a shebang line in a Python file?

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.

What should setup py contain?

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.

Where is shebang written in a Python file?

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.


1 Answers

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!?"

like image 101
Klaus D. Avatar answered Sep 18 '22 01:09

Klaus D.