[mod_python] patch to use Py_SetProgramName()

Graham Dumpleton graham.dumpleton at gmail.com
Wed Mar 26 16:51:58 EDT 2008


On 27/03/2008, Glen W. Mabey <Glen.Mabey at swri.org> wrote:
> On Wed, Mar 26, 2008 at 03:15:51PM -0500, Graham Dumpleton wrote:
>  > >  with the Py_SetProgramName() function.  Since configure is already
>  > >  getting this value explicitly (when --with-python is used), it seems to
>  > >  me that it would be desirable to employ this facility instead of letting
>  > >  Py_Initialize() search around for what it decides is the most
>  > >  appropriate executable.
>  > >
>  > >  Is that reasonable?
>  >
>  > Except that it doesn't work for Windows or MacOS X.
>  >
>  > Anyway, see:
>  >
>  >   http://issues.apache.org/jira/browse/MODPYTHON-225
>  >
>  > It also talks about workaround of setting PYTHONEXECUTABLE or
>  > PYTHONHOME environment variables in 'envvars' file or Apache startup
>  > script.
>
>
> Humm.  Seems to be a fairly well explored problem already.
>
>  Now, I'm often wrong on this sort of thing, and I certainly don't have
>  any experience deploying apache on Windows or MacOSX, but I wonder
>  whether the use of Py_SetProgramName() is detrimental on those
>  platforms?
>
>  That is, if it fixes the problem on certain platforms (or, if it is one
>  way to fix it), then is it worth including?

Even if it fixes things on some platforms, the problem I have with it
is that it hard codes a path into the executable. If the 'python'
executable supplied to --with-python was actually a symlink to another
location, the result will be an incorrect location is used as you
really want the location pointed at, not where the symlink was.
Another problem might be where people building binary distributions of
mod_python use some special Python installation not in the standard
location. It may work for them when they test it, but when they
release it it then make break for others because they may not have
Python installed where person who built it did.

What was found with mod_wsgi was that it was better to have a
directive in Apache configuration file which allowed one to set
PYTHONHOME. This still didn't work for Windows, but seemed the best
compromise. One benefit of making it configurable through the Apache
configuration file was that that mechanism could then be used to point
the interpreter at a Python virtual environment isolated from
site-packages of standard Python installation. For details on this
see:

  http://code.google.com/p/modwsgi/wiki/VirtualEnvironments

You might also read section 'Multiple Python Versions' of:

  http://code.google.com/p/modwsgi/wiki/InstallationIssues

which for mod_wsgi talks about the same problem with wrong version of
Python being found.

Graham


More information about the Mod_python mailing list