[katello-devel] Why #!/usr/bin/env ?

Eric Sammons esammons at redhat.com
Wed Jul 25 15:51:04 UTC 2012


> 
> +1
> 
> By the way this is recommended by default in Fedora 16+:
> 
> http://fedoraproject.org/wiki/Features/SystemPythonExecutablesUseSystemPython
> 
> I guess I would be able to find it in packaging guidelines somewhere.
> I
> am pretty sure I have been fixing those at least two times for my
> (few)
> fedora packages. Even rpmlint warns about it I believe!
> 
> Therefore: Do not use env, use direct path.

That document makes sense for Fedora and testing where you want to test the shipped version of python; however, it is also important to note that the document contradicts itself.

'''
System executables written in Python now use a shebang line that explicitly references the system version of Python.

Remove the "#!/usr/bin/env python" shebang line from python executables, replacing with "#!/usr/bin/python"
'''

Tells you in Fedora for testing of /usr/bin/python you should replace the #!/usr/bin/env python line in your code.

_HOWEVER_ if you read the Detailed description and Benefit to Fedora it seems they are arguing for the continued use of #!/usr/bin/env python.

'''
Benefit to Fedora

Users will be able to parallel-install local copies of older and newer releases of Python on the system and add them to the front of their PATH without breaking these executables. (e.g. Python 2.4 for Zope, or Python 3)
'''

Unless I missed something, the above statement is _only_ true if you are using #!/usr/bin/env python.  As installing multiple python binaries and then prepending your $PATH, will have no impact on a python program using #!/usr/bin/python.  

With that being said, I'll continue using #!/usr/bin/env python.

http://docs.python.org/using/unix.html#miscellaneous Section 2.4. Miscellaneous




More information about the katello-devel mailing list