mod_wsgi 2.4 with macports python 2.6

Monday, April 13th, 2009 at 22:39

Update 2009-10-23: This post is totally obsolete. Snow Leopard is out and mod_wsgi 2.5 is available in macports.

Update 2009-05-11: mod_wsgi 2.5 is now available, check out my post on mod_wsgi 2.5 with macports python 2.6 instead.

Quick how-to

  • wget http://modwsgi.googlecode.com/files/mod_wsgi-2.4.tar.gz
  • tar -xzvf mod_wsgi-2.4.tar.gz && cd mod_wsgi-2.4 && ./configure
  • Edit Makefile with your favorite editor, replace everything after the = on the LDFLAGS line with the output from python2.6-config –ldflags
  • make && sudo make install and restart apache when done.
  • Confirm with otool -L /opt/local/apache2/modules/mod_wsgi.so

Long story

Macports can be a pain sometimes. I think I will switch to a python.org package of python soon and through out python from my macports. Anyway I just wanted to share how I compilled mod_wsgi 2.4 for my macports installed apache2 and python 2.6. Since the current version of mod_wsgi at the time of writing this is the obsolete 1.1 I went to modwsgi.org and downloaded the source for 2.4.

First I just ran ./configure, make, sudo make install as usual when compiling stuff. Everything seemed fine but I noticed some wierdness in the apache error log:

[Mon Apr 13 17:26:57 2009] [warn] mod_wsgi: Compiled for Python/2.6.1.
[Mon Apr 13 17:26:57 2009] [warn] mod_wsgi: Runtime using Python/2.5.1.

Apparently my mod_wsgi was indeed compiled against the correct python but for some reason it went witht he os x python in runtime, which screwed up a lot of things.

After a lot of googling I was pretty sure I needed to edit the generated Makefile by ./configure to solve this problem. The output from:

$ otool -L /opt/local/apache2/modules/mod_wsgi.so

clearly showed os x shipped python 2.5 invloved somehow. None of the suggestions in the links I found gave me the correct LDFLAGS needed to compile it proper. Instead after some more googling I found this which learned me that I could just run:

$ python2.6-config --ldflags

to get the correct ldflags. I took the output of the above command and put it into the mod_wsgi ./configure generated Makefile on the LDFLAGS line then just make and sudo make install.

Restarting apache now showed me

Apache/2.2.11 (Unix) mod_ssl/2.2.11 OpenSSL/0.9.8k DAV/2 mod_wsgi/2.4 Python/2.6.1 configured -- resuming normal operations

3 Responses to “mod_wsgi 2.4 with macports python 2.6”

  1. Andreas says:

    I posted the requested data on the bug report.

  2. Please provide more details as requested on mod_wsgi ticket you commented on.

    I have never been quite able to get correct information out of people to work out what MacPorts is doing that is different to normal.

  3. [...] Graham Dumpleton released mod_wsgi 2.5 today. He’s has implemented workarounds on the issues I had while compiling mod_wsgi 2.4 with macports python 2.6. [...]

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>