05-11-07 12:12 PM
Allow Python executable location and Python home to be specified.
-----------------------------------------------------------------
Key: MODPYTHON-225
URL: https://issues.apache.org/jira/browse/MODPYTHON-225
Project: mod_python
Issue Type: New Feature
Components: core
Affects Versions: 3.3.1
Reporter: Graham Dumpleton
Where a user has multiple versions of Python installed getting mod_python to
work can be problematic.
The main issue is where a version of Python is installed in a location diffe
rent to where the standard operating system version is installed. For exampl
e, if /usr/bin/python is Python version 2.4 and a user has installed Python
version 2.5 as /usr/local/b
in/python. And the user has compiled mod_python against Python 2.5 and not t
he operating system version 2.4.
Under normal circumstances Apache is only going to look in /usr/bin when sta
rted from an init.d script and not in /usr/local/bin. The result of this is
that Python when initialised will find /usr/bin/python and assume that that
is the base it should use t
o start with to find where the Python library files are installed. In doing
this though it will not be able to find /usr/lib/python2.5 as what it really
needs to be able to find is /usr/local/lib/python2.5. The final outcome wil
l be that mod_python will n
ot be able to find the Python code files for itself when starting up.
The only way around this is to set the PATH environment variable in the star
tup scripts for Apache to look in /usr/local/bin before /usr/bin. Alternativ
ely, on some UNIX platforms (but not necessarily all) it is possible to set
the environment variable PY
THONEXECUTABLE to be the exact location of the Python executable specified w
hen configuring mod_python. Finally, on UNIX platforms one can also set PYTH
ONHOME to be the exact location of either a shared platform independent/depe
ndent Python library direct
ory, or where separate directories a colon separated list of the two directo
ries. In the latter Python will skip the whole search process and simply use
the two values.
Having to use environment variables to do this can be a pain as it may be ne
cessary to modify init.d startup scripts to make it work. What should really
be done is that mod_python should provide for UNIX platforms the directives
PythonExecutable and Pytho
nHome as equivalents to using the PYTHONEXECUTABLE and PYTHONHOME environmen
t variables. These values if defined can be used in calls to Py_SetProgramNa
me() and Py_SetPythonHome() appropriately.
This will allow the Apache configuration file itself to be used to qualify w
hich version of Python should be used when non standard versions not in the
standard locations are being used.
Note that these directives shouldn't be required on the Windows platform as
it uses the Windows registry to find where the Python library files are loca
ted.
[ Post a follow-up to this message ]
|