[mod_python] patch to use Py_SetProgramName()

Glen W. Mabey Glen.Mabey at swri.org
Thu Mar 27 10:57:05 EDT 2008

On Wed, Mar 26, 2008 at 03:51:58PM -0500, Graham Dumpleton wrote:
> 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.

My impression from the description of the Py_SetProgramName() function
was that it provided not so much of a hard-coding to the path but rather
steering the search for the executable to first look at a specific
location before looking in other likely places.

Has that been your experience in using Py_SetProgramName()?

> What was found with mod_wsgi was that it was better to have a
> directive in Apache configuration file which allowed one to set

Apparently, the use of PYTHONHOME would still override the value given
to Py_SetProgramName(), so it doesn't seem to me that you would lose any 
flexibility by its use.

> 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.

One reason for my terseness in my original post was that I couldn't see
any reason (at the time) for not employing Py_SetProgramName(), since it
seemed to me to be the preferred mechanism (if the executable path is
known at compile time) to *correctly* specify the path for a package 
maintainer whose work will end up on other people's systems.  Or to give a 
person like myself (targeting a specialized type of installation) to use 
a symlink that actually points to the desired interpreter, without the
need to define PYTHONHOME (that has complicated things in the past

Anyway, thank you for you attention.

Glen Mabey

More information about the Mod_python mailing list