Re: shebang lines for Python scripts
On Friday, March 04, 2011 01:23:40 pm Barry Warsaw wrote:
> So I know many of you are on python-dev, so you might have seen this come
> up, but traffic there can be pretty heavy at times.
>
> Upstream Python recommends that the shebang line for scripts should be
>
> #!/usr/bin/env python
>
> however, this should only apply to *developer* packages, not operating
> system packages. Doing the above in packages provided by the distro can
> cause those scripts to break, if say a user installs their own Python
> sooner in $PATH, and which is not compatible with the script.
>
> It's also unnecessary for distros because we should know exactly which
> version of Python our scripts work with. And finally, setuptools will
> rewrite the shebang line when it installs scripts (FSVO 'setuptools' ;).
>
> There's about two such scripts in /usr/bin on my Squeeze machine. Debian
> policy should be clear that system installed Python scripts should have a
> shebang line hardcoded to a Python executable. Whether that should be
> /usr/bin/python, /usr/bin/python2, /usr/bin/pythonX.Y or something else is
> a different discussion. ;) Personally /usr/bin/python seems fine to me
> for now.
>
> -Barry
Currently Python policy says:
1.4.2. Interpreter Location
---------------------------
The preferred specification for the Python interpreter is
`/usr/bin/python' or `/usr/bin/python<X>.<Y>'. This ensures that a
Debian installation of python is used and all dependencies on
additional python modules are met.
If a maintainer would like to provide the user with the possibility to
override the Debian Python interpreter, he may want to use
`/usr/bin/env python' or `/usr/bin/env python<X>.<Y>'. However this
is not advisable as it bypasses Debian's dependency checking and makes
the package vulnerable to incomplete local installations of python.
Is that strong enough?
Scott K
Reply to: