Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.
  • Root
  • » Django
  • » Building mod_python 3.3.1 for Python 2.5.2 on Mac OS X 10.5.2 (Leopard) [RSS Feed]

#1 March 24, 2008 11:41:56

Jeffrey A.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Building mod_python 3.3.1 for Python 2.5.2 on Mac OS X 10.5.2 (Leopard)


I had trouble building mod-pyhon 3.3.1 on Mac OS X 10.5.2 (Leopard),
so I thought I would share the solution here. I posted this yesterday
to the mod_python mailing list and I incorporated the suggestion I
received from there below.

I have installed Python 2.5.2 into /usr/local (to use instead of
Leopard's default 2.5.1 distribution). It is not that v2.5.2 provides
so many improvements over v2.5.1; rather, Apple has shown in the past
that they do not upgrade their version of Python between major OX X
updates, and I would like to be able to take advantage of all future
improvements in v2.5.x and soon v2.6.x (possibly as early as this
summer).

I have also installed the Apache 2.2.8 web server (instead of Apples
default Apache server, which I think is also v2.2.8).

I did not touch/modify Apple's default Python 2.5.1 or Apache 2.2.8
installations in any way.

First, I will describe the problem and then I will show the *solution*
that solves this problem.



Problem:

If you perform a normal mod_python build, the copy of mod_python.so
that is created by the build process has the python module import
paths from Apple's Python 2.5.1 installation *hardwired* into it. I
know this is so because I looked into the mod_python.so file (even
though this is a binary file), and I could see strings that referred
to Apple's Python 2.5.1 installation.

Note that this occurred even though I specified the mod_python
configure option:

--with-python=/usr/local/bin/python2.5

(which is the Python 2.5.2 installation I installed myself).

When I tried to connect to my Apache 2.2.8 web server with a request
that was routed to mod_python (such as the /mpinfo testhandler), I
received a generic 500 Server Error page in my web browser and the
Apache error log file contained the following:

python_init: Python version
mismatch, expected '2.5.2', found '2.5.1'.
python_init: Python executable
found '/usr/local/bin/python'.
python_init: Python path being used
'/System/Library/Frameworks/Python.framework/Versions/2.5/lib/
python25.zip:/System/Library/Frameworks/Python.framework/Versions/2.5/
lib/python2.5/:/System/Library/Frameworks/Python.framework/Versions/
2.5/lib/python2.5/plat-darwin:/System/Library/Frameworks/
Python.framework/Versions/2.5/lib/python2.5/plat-mac:/System/Library/
Frameworks/Python.framework/Versions/2.5/lib/python2.5/plat-mac/lib-
scriptpackages:/System/Library/Frameworks/Python.framework/Versions/
2.5/lib/python2.5/../../Extras/lib/python:/System/Library/Frameworks/
Python.framework/Versions/2.5/lib/python2.5/lib-tk:/System/Library/
Frameworks/Python.framework/Versions/2.5/lib/python2.5/lib-dynload'.
mod_python: Creating 32 session
mutexes based on 256 max processes and 0 max threads.
mod_python: using mutex_directory /
tmp
Digest: generating secret for
digest authentication ...
Digest: done
Apache/2.2.8 (Unix) mod_ssl/2.2.8
OpenSSL/0.9.7l DAV/2 mod_python/3.3.1 Python/2.5.1 SVN/1.4.6
configured -- resuming normal operations

Notice that even though the Apache process found Python 2.5.2 in /usr/
local/bin (I was careful to set the PATH environment variable
appropriately in my launchctl configuration file for the web server),
the python module import paths all seem to refer to Apple's default
Python 2.5.1 distribution (which does not have the mod_python package
installed, of course). Needless to say, mod_python was not useable.



Solution:

1. Before building mod_python, execute:

$ cd /System/Library/Frameworks
$ sudo mv Python.framework XXX_Python.framework

2. After building mod_python, revert this change with:

$ cd /System/Library/Frameworks
$ sudo mv XXX_Python.framework Python.framework

In other words, the build process should look something like the
following (the configure options you choose may be different that
those I used):

$ cd /System/Library/Frameworks
$ sudo mv Python.framework XXX_Python.framework

$ cd <mod_python distribution directory>
$ ./configure \
> --with-apxs=/usr/local/apache2/bin/apxs \
> --with-python=/usr/local/bin/python2.5 \
> --with-max-locks=32
$ make
$ sudo make install

$ cd /System/Library/Frameworks
$ sudo mv XXX_Python.framework Python.framework



Conjecture:

I am not a C programmer, but I would guess that there is a slight
problem with the build system for mod_python on Leopard that needs to
be fixed. If you supply the configure option:

--with-python=/usr/local/bin/python2.5

the build process should ignore everything to do with Apple's Python
2.5.1 distribution, but it does not. It seems that the "sudo mv ..."
commands from the recipe above are enough to temporarily hide Apple's
Python 2.5.1 distribution from the mod_python build system so that a
mod_python.so module can be built that is solely dependendent on the
Python 2.5.2 distribution I specified in the configure options. Let's
hope that the mod_python distribution is updated soon so that others
are not bitten by this bug.

After posting this message to the mod_python mailing list, I was
informed that this is a known issue. It appears that the "fix" I
describe above can be used to circumvent this issue if you use the
current version (3.3.1) of mod_python. But the developers are working
on a fix to this problem and suggest that the development version from
their subversion repository can be used instead. See:http://www.modpython.org/pipermail/mod_python/2008-March/025048.htmlhttp://www.modpython.org/pipermail/mod_python/2008-March/024954.html

Jeffrey


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en-~----------~----~----~----~------~----~------~--~---

Offline

  • Root
  • » Django
  • » Building mod_python 3.3.1 for Python 2.5.2 on Mac OS X 10.5.2 (Leopard) [RSS Feed]

Board footer

Moderator control

Enjoy the 11th of December
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support