[Python-Dev] [PATCH] Handling of scripts (original) (raw)

[Python-Dev] [PATCH] Handling of scripts / substitution of python executable path

"Martin v. Löwis" martin at v.loewis.de
Fri Feb 23 22:33:01 CET 2007


Hans Meine schrieb:

For a long time, I have been annoyed by distutils behavior concerning "scripts": I always put #!/usr/bin/env python into the first line in order to let the incredibly useful "env" program start the right python version.

I know that it is quite evil to hardcode /usr/bin/python

No. The current distutils behaviour is very deliberate, intentional, and has undergone a number of iterations to arrive at this point.

While it is true that you would normally use /usr/bin/env for scripts that you distribute, it's not true that you should use that for scripts that you install. Instead, the script that you install will likely depend on the specific installation of Python: the script will likely use modules that are only installed in a single location. So the installed scripts need to hard-code the path to the interpreter, or else they break if somebody changes the path and suddenly picks up a different Python.

Notice that it may not just be that the Python is a different version (on which the script won't work); it may also be that the it won't work on a different installation of the same Python version, since it requires libraries not available in this other installation.

So the default must stay as it is.

Regards, Martin



More information about the Python-Dev mailing list