mod_wsgi broke after upgrading to Snow Leopard

24 views
Skip to first unread message

Andrey Fedorov

unread,
Aug 30, 2009, 5:21:45 PM8/30/09
to modwsgi
Hi All,

I'm running apache 2.2.1 installed using MacPorts and mod_wsgi
compiled using online instructions [2]. After upgarding my MBP to
10.6, I get the following in my apache's error.log when I try to load
a page:

> [error] [client ::1] Premature end of script headers: django.wsgi

WSGI FAQ [1] suggests:

> If using daemon mode, this is a symptom of the mod_wsgi daemon process crashing when handling a request. You would probably also see the message 'segmentation fault'. See answer for question about 'segmentation fault' above.

The referred section above says:

> This is nearly always caused due to mod_python also being loaded by Apache at the same time as mod_wsgi and the Python installation not providing a shared library, or mod_python having originally being built against a static Python library. This is especially a problem with older Linux distributions before they started shipping with Python as a shared library.

Apache seems to be configured correctly (hasn't changed since before
install), and mod_python isn't being loaded.

I tried rebuilding mod_wsgi using the same instructions [2] I did last
time, but I get an error when I `make` spanning 9k lines [3], the
short version being:

> [...]
> `lipo: can't figure out the architecture type of: <some temp file>.out`

I did a bunch of other poking around - making sure I'm running the
installation of Apache I think I'm running, the config files loaded
are the ones I'm looking at, etc, but I'm running out of
troubleshooting steps. Solutions and advice for next step both
welcome :)

[1]: http://code.google.com/p/modwsgi/wiki/FrequentlyAskedQuestions
[2]: http://god.morgon.nu/2009/05/11/mod_wsgi-25-with-macports-python-26/
[3]: http://gist.github.com/177914

Graham Dumpleton

unread,
Aug 30, 2009, 7:37:29 PM8/30/09
to mod...@googlegroups.com
I fully expected that trying to use MacPorts on Snow Leopard is going
to be a whole world of hurt for a while.

I would suggest first off that you see if you can get mod_wsgi working
with Apple supplied Apache and Python. Try mod_wsgi 2.5 first and if
that has issues, try 3.0c4.

My Snow Leopard will hopefully arrive today, but not entirely sure
whether I will upgrade straight away yet or not. Even so, I will only
be checking with Apple supplied Apache and Python as I don't use
MacPorts because of the pain it always creates due to not being 64
bit.

Graham

2009/8/31 Andrey Fedorov <anfe...@gmail.com>:

Graham Dumpleton

unread,
Aug 30, 2009, 7:47:02 PM8/30/09
to mod...@googlegroups.com
Okay, I have looked at the compiled output and you are perhaps using
standard Apache tools.

Can you use spotlight to find location of 'httpd.h' on Snow Leopard.
Doesn't look to be in place it is supposed to be.

I wander if Snow Leopard requires special package to be installed to
allow code development against new versions of programs.

Graham

2009/8/31 Graham Dumpleton <graham.d...@gmail.com>:

Graham Dumpleton

unread,
Aug 30, 2009, 8:11:31 PM8/30/09
to mod...@googlegroups.com
2009/8/31 Graham Dumpleton <graham.d...@gmail.com>:
> Okay, I have looked at the compiled output and you are perhaps using
> standard Apache tools.
>
> Can you use spotlight to find location of 'httpd.h' on Snow Leopard.
> Doesn't look to be in place it is supposed to be.
>
> I wander if Snow Leopard requires special package to be installed to
> allow code development against new versions of programs.

Also validate what is in:

/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6

as it isn't find header files in there either.

Send a directory listing of what is in that directory as well as:

/usr/include/apache2

Also provide output from running:

which gcc

The issue may be that it is finding MacPorts gcc and it is broken in
some way on Snow Leopard.

Graham

Graham Dumpleton

unread,
Aug 30, 2009, 10:15:30 PM8/30/09
to mod...@googlegroups.com
Did you install XCode from the optional installs directory of the Snow
Leopard disk?

None of the required header files are installed with the base
operating system release.

So, if not installed, likely you are using MacPorts gcc, but can't
find any installed header files to compile against.

I should start considering supplying dmg file containing mod_wsgi.so
for MacOS X Snow Leopard.

Graham Dumpleton

unread,
Aug 30, 2009, 10:25:12 PM8/30/09
to mod...@googlegroups.com
BTW, the command line Python in Snow Leopard is now also 64 bit.

$ file /usr/bin/python
/usr/bin/python: Mach-O universal binary with 3 architectures
/usr/bin/python (for architecture x86_64): Mach-O 64-bit executable x86_64
/usr/bin/python (for architecture i386): Mach-O executable i386
/usr/bin/python (for architecture ppc7400): Mach-O executable ppc

Under Leopard it was 32 bit only, but with 32/64 bit Python framework.
This is why could run 64 bit under Apache/mod_wsgi.

That it is now 64 bit should be interesting. I presume though they
will have had the sense to patch distutils so that when building third
party extension modules it will build all architectures automatically,
where as in Leopard it only built 32 bit extensions still. This has
meant that third party Python modules have had to be made MacOS X
aware to get them to build 64 bit explicitly.

Andrey Fedorov

unread,
Aug 31, 2009, 3:26:51 AM8/31/09
to mod...@googlegroups.com
Did you install XCode from the optional installs directory of the Snow Leopard disk?

No, I hadn't realized I needed to reinstall it.


Send a directory listing of what is in that directory as well as: /usr/include/apache2

Looks like everything is here after I re-installed XCode: https://gist.github.com/66d0c70f0886589258e6

And everything went through all right (albeit with a couple of warnings):

fedorov$ make
/usr/sbin/apxs -c -I/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 -DNDEBUG -DENABLE_DTRACE  -Wc,'-arch x86_64' -Wc,'-arch i386' -Wc,'-arch ppc7400' mod_wsgi.c -L/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/config  -arch x86_64 -arch i386 -arch ppc7400 -lpython2.6 -ldl
/usr/share/apr-1/build-1/libtool --silent --mode=compile gcc    -DDARWIN -DSIGPROCMASK_SETS_THREAD_MASK -I/usr/local/include -I/usr/include/apache2  -I/usr/include/apr-1   -I/usr/include/apr-1  -arch x86_64 -arch i386 -arch ppc7400 -I/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 -DNDEBUG -DENABLE_DTRACE  -c -o mod_wsgi.lo mod_wsgi.c && touch mod_wsgi.slo
mod_wsgi.c: In function ‘Adapter_output’:
mod_wsgi.c:2428: warning: format ‘%d’ expects type ‘int’, but argument 3 has type ‘Py_ssize_t’
mod_wsgi.c: In function ‘Adapter_output’:
mod_wsgi.c:2428: warning: format ‘%d’ expects type ‘int’, but argument 3 has type ‘Py_ssize_t’
mod_wsgi.c: In function ‘Adapter_output’:
mod_wsgi.c:2428: warning: format ‘%d’ expects type ‘int’, but argument 3 has type ‘Py_ssize_t’
/usr/share/apr-1/build-1/libtool --silent --mode=link gcc -o mod_wsgi.la  -rpath /usr/libexec/apache2 -module -avoid-version    mod_wsgi.lo -L/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/config -arch x86_64 -arch i386 -arch ppc7400 -lpython2.6 -ldl
warning: no debug symbols in executable (-arch x86_64)
warning: no debug symbols in executable (-arch i386)
warning: no debug symbols in executable (-arch ppc7400)

Thanks! :)

- Andrey

Graham Dumpleton

unread,
Aug 31, 2009, 3:39:46 AM8/31/09
to mod...@googlegroups.com
2009/8/31 Andrey Fedorov <anfe...@gmail.com>:
>> Did you install XCode from the optional installs directory of the Snow
>> Leopard disk?
>
> No, I hadn't realized I needed to reinstall it.

I didn't either until I upgraded. :-)
This is only in an error log message and nothing to worry about. I
have fixed it for mod_wsgi 3.0.

> /usr/share/apr-1/build-1/libtool --silent --mode=link gcc -o mod_wsgi.la
> -rpath /usr/libexec/apache2 -module -avoid-version    mod_wsgi.lo
> -L/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/config
> -arch x86_64 -arch i386 -arch ppc7400 -lpython2.6 -ldl
> warning: no debug symbols in executable (-arch x86_64)
> warning: no debug symbols in executable (-arch i386)
> warning: no debug symbols in executable (-arch ppc7400)

I don't know what to make of those, but doesn't seem to cause any problems.

Graham
Reply all
Reply to author
Forward
0 new messages