Hot to get Python executable's path ??

Paul Watson pwatson at redlinepy.com
Sat Jun 14 19:04:37 CEST 2003


What is the general feeling on executable expectations?

Should python apps:

Detect or get the executable path to python and rewrite shebang (#!) lines
at setup.py time
  + known to work at install time
  - need to provide process to update to new Python version if user moves or
removes old version

Run with whatever is provided by #! /usr/bin/env python
  + no need to rewrite #! lines
  - at the mercy of whatever is in the path

Code #!/usr/bin/python and expect the sysadmin to create it
  - might require sysadmin (user) to create/manage the link correctly
  - might not be Windows friendly

In all cases, the app needs to determine that the interpreter under which it
has been invoked is an appropriate version and has needed components.

Are there other solutions and tradeoffs?


"vivek kumar" <gupt_vive at hotmail.com> wrote in message
news:mailman.1055583626.30429.python-list at python.org...
> Hi all,
>
>   I am writing a CGI app. I was trying to find out a way to change the #!
> line in the CGI scripts for different platforms using an install script.
> Like as I am developing it on windows so the line says
>
>          #!c:\python22\python.exe
>
> Now on linux it may be /usr/bin/python or /usr/local/bin/python and on
> windows also it may be anywhere the user has installed it. So is there any
> way to find out the path for that. I tried
>
>           distutils.sysconfig.get_config_var(...)
>
> with "exec_prefix" and "prefix". But on linux it showed me /usr only ? So
is
> there any way to find the path for the Installed Python executable to
> substitute it in my CGI scripts?
>
> TIA and Kind Regards
> Vivek Kumar
>
> _________________________________________________________________
> Dress up your desktop! Get the best wallpapers.
> http://server1.msn.co.in/msnchannels/Entertainment/wallpaperhome.asp Just
> click here!
>
>






More information about the Python-list mailing list