#!/bin/env problem Was: Re: Backwards emulation rather than backwards compatibility?

Berthold Höllmann bhoel at web.de
Wed May 29 17:50:06 EDT 2002


Oleg Broytmann <phd at phd.pp.ru> writes:

> On Tue, May 28, 2002 at 02:43:53PM -0700, Dave Kuhlman wrote:
> > I typically start my scripts with a first line like the following:
> > 
> >     #! /usr/bin/env python
> > 
> > Quite a few files in Python2.2.1/Lib do likewise.
> > 


> 
>    Parsing the #! header is the job of the OS kernel, and all unicies do it
> in the very simple way - they split the header into an interpreter
> (/usr/bin/env, in this case) and its flags (python -t). Flags ARE NOT
> SUPPOSED to have spaces, and are apssed to the interpreter as is.
> 
>    So the only way is to write
> 
> #! /usr/local/bin/python -O
> 
>    as I always do.
> 
>    If you want to distribute the script and worry about portability problem
> - write setup.py and use "script" option. Distutils rocks!
Only as long as you don't fiddle with the installation to support
multiple architectures. If you install Python using different
argunents for the configure options --prefix and --exec-prefix to put
all achitecture independent files into one directory, installing
scripts using distutils becomes a problem. Distutils will replace the
#! line with the path to the interpreter for the architecture you are
doing the install, but installs the script into the acrchitecture
independent bin directory. That is a bad idea. Installing them into
the architecture dependent directory is not much better when the
script is subject to changes because the install has to be done for
all architectures you support, but the idea of the
--prefix/--exec-prefix was to make support for different architectures
easier. 

Greetings

Berthold

-- 
bhoel at web.de / http://starship.python.net/crew/bhoel/
        It is unlawful to use this email address for unsolicited ads
        (USC Title 47 Sec.227). I will assess a US$500 charge for
        reviewing and deleting each unsolicited ad.



More information about the Python-list mailing list