#! to two different pythons?

Duncan Booth duncan.booth at invalid.invalid
Sun Jun 7 11:43:54 CEST 2009


mh at pixar.com wrote:

> Benjamin Peterson <benjamin at python.org> wrote:
>> #!/usr/bin/env python
> 
> But how can I handle this with two differently named pythons?
> 
>     #!/usr/anim/menv/bin/pypix
>     #!/Users/mh/py/bin/python
> 
> Thanks!
> Mark
> 

If you install using with a setup.py that uses distutils then one of the  
features is that any script whose first line begins '#!' and contains 
'python' has that first line replaced by the current interpreter.

So in this example if you install your code with:

   /usr/anim/menv/bin/pypix setup.py install

"#!/usr/bin/env python" would be replaced by your desired 
"#!/usr/anim/menv/bin/pypix".

Of course for your current purposes using setup.py might be overkill.



More information about the Python-list mailing list