From: Richard J. <rj...@ek...> - 2002-11-13 03:16:33
|
On Wed, 13 Nov 2002 12:30 pm, David Goodger wrote: > General tip: at the top of script files, don't use:: > > #!/usr/bin/python > > Please use this instead:: > > #! /usr/bin/env python > > The former is hard-coded. For example, it finds Python 1.5.2 on > RedHat. The latter finds an executable called "python" on the user's > path. I've set up my environment so Python 2.2 is found first. Some > people will have their Python interpreter at /usr/local/bin/python or > non-standard places. A better scheme which is used in moinmoin and roundup setup.py installers is to munge the #! line when the script is installed so that it is hard-coded to use the same interpreter that ran the setup.py file. It also generates a .bat wrapper on windows that does an analogous thing for windows. As Aahz pointed out, some people are touchy about "/usr/bin/env python". Being a sad little redhat user, even that line won't work for me because the real python is called "python2" on my system. The above setup.py trick automatically handles that situation. Someone mentioned to me that distutils (possibly recent versions) does some sort of automagic munging of that line itself, but I haven't had a chance to look into it. Richard |