Success! [Was: Re: [mod_python] Trouble on OSX - Leopard]

Graham Dumpleton graham.dumpleton at gmail.com
Tue Oct 30 17:00:40 EDT 2007


Bouncing this back to the list so anyone else wanting to get it
working on Leopard knows the magic.

One thing I would like to see though. Can you dig into the
lib/python2.5/config directory of your Python installation and post
extract from there which shows the compiler flags that Python itself
uses when building extension modules. We may find that it has the
-arch flags in there, but both mod_python and mod_wsgi ignore them for
various reasons.

Thanks for tracking this through.

Graham

On 31/10/2007, Ben Mitchell <ben at mitchellfamily.com> wrote:
>
> OK.  I got it!
>
> At this point, both mod_wsgi and mod_python appear to be installed and
> working properly.
>
> For mod_python I had to make the following modifications to
> .../src/Makefile:
>
> Add -arch x86_64 to the LDFLAGS line
>
> Change the build line in mod_python.so to:
> $(APXS) $(INCLUDES) -c -Wc,"-arch x86_64" $(SRCS) $(LDFLAGS) $(LIBS)
>
> I'm sure there's a cleaner / more generic way to make this happen, but I was
> more interested in "getting 'er done" at this point.
>
> mod_wsgi was easier.  I actually built it as a "universal binary":
> CPPFLAGS = -Wc,"-arch ppc" -Wc,"-arch i386" -Wc,"-arch x86_64"
> -I/System/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5
> -DNDEBUG -DMACOSX -DENABLE_DTRACE
> CFLAGS = -Wc,"-arch ppc" -Wc,"-arch i386" -Wc,"-arch x86_64"
> LDFLAGS = -arch ppc -arch i386 -arch x86_64 -framework Python -u
> _PyMac_Error -framework Python
>
> Thanks again for all your help.  I really appreciate it.
>
> -Ben
>
>
>
> On Oct 30, 2007, at 3:13 AM, Graham Dumpleton wrote:
> Hmmm, if that is a bit odd.
>
> BTW, what architectures are included in mod_wsgi.so/mod_python.so if
> you force use of compiler options:
>
>   -arch ppc -arch i386
>
> Check the gcc man page for what are the choices for -arch on Leopard.
>
> Graham
>
> On 30/10/2007, Ben Mitchell <ben at mitchellfamily.com> wrote:
> Graham,
>
> Made some progress...
>
> Here's what appears to be the problem:
>
>
> [Macintosh:local/src/mod_wsgi-1.2] benha% make
> /usr/sbin/apxs -c -Wc,-m64
> -I/System/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5
> -DNDEBUG -DMACOSX -DENABLE_DTRACE -Wc,-m64 mod_wsgi.c -m64 -framework Python
> -u _PyMac_Error -framework Python -ldl
> /usr/share/apr-1/build-1/libtool --silent --mode=compile
> gcc    -DDARWIN -DSIGPROCMASK_SETS_THREAD_MASK -no-cpp-precomp
> -I/usr/include/apache2  -I/usr/include/apr-1   -I/usr/include/apr-1  -m64
> -m64
> -I/System/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5
> -DNDEBUG -DMACOSX -DENABLE_DTRACE  -c -o mod_wsgi.lo mod_wsgi.c && touch
> mod_wsgi.slo
> /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 -m64 -framework Python -u _PyMac_Error -framework Python -ldl
> ld: warning in
> /Library/Frameworks//Python.framework/Python, missing
> required architecture x86_64 in file
> Per the last line, ld doesn't believe Python has a 64-bit version and, as a
> result, isn't linking it.  Same problem is breaking the build on mod_python.
>
> Curiously, an inspection of Python implies that it has a 64-bit version:
>
>
> [Macintosh:Library/Frameworks/Python.framework] benha% file
> Python
> Python: Mach-O universal binary with 4 architectures
> Python (for architecture ppc7400): Mach-O dynamically linked shared library
> ppc
> Python (for architecture ppc64): Mach-O 64-bit dynamically linked shared
> library ppc64
> Python (for architecture i386): Mach-O dynamically linked shared library
> i386
> Python (for architecture x86_64): Mach-O 64-bit dynamically linked shared
> library x86_64
>
> Anyway, that's pretty clearly the issue.  No solution yet, but I thought
> you'd like to know...
>
> -Ben
>
>
>
> On Oct 29, 2007, at 10:47 PM, Graham Dumpleton wrote:
> The one with mod_wsgi looks like it isn't linking Python Framework any
> more. So, keep also checking with otool -L as well to make sure Python
> library dependency is there.
>
> Let me know what you work out.
>
> Graham
>
> On 30/10/2007, Ben Mitchell <ben at mitchellfamily.com> wrote:
> Hrmmm...
>
> Not working.  I had to add the same flags to both CFLAGS and LDFLAGS to get
> it to make a 64-bit version (not sure that was the right move).  But now I
> get this:
>
>
> sh-3.2# file /usr/libexec/apache2/mod_python.so
> /usr/libexec/apache2/mod_python.so: Mach-O 64-bit bundle
> x86_64
> sh-3.2# apachectl configtest
> httpd: Syntax error on line 116 of
> /private/etc/apache2/httpd.conf: Can't locate API module
> structure `python_module' in file
> /usr/libexec/apache2/mod_python.so: dlsym(0x1002179c0,
> python_module): symbol not found
>
> Got something similar for mod_wsgi:
>
>
> sh-3.2# apachectl configtest
> httpd: Syntax error on line 117 of
> /private/etc/apache2/httpd.conf: Cannot load
> /usr/libexec/apache2/mod_wsgi.so into server:
> dlopen(/usr/libexec/apache2/mod_wsgi.so, 10): Symbol not
> found: _PyExc_RuntimeError\n  Referenced from:
> /usr/libexec/apache2/mod_wsgi.so\n  Expected in: dynamic
> lookup\n
>
>
> Anyway, I don't want to consume your evening with this :-)  I'll keep
> plugging away at it.  I really appreciate the help.  I think I'm at least on
> the right track now.
>
> -Ben
>
> On Oct 29, 2007, at 10:23 PM, Graham Dumpleton wrote:
> Try editing Makefile and adding option to CFLAGS:
>
>   CFLAGS = -Wc,-m64
>
> At least I think that -m64 is the option. The -Wc, bit is to get it
> past apxs/libtool build tool.
>
> Graham
>
> On 30/10/2007, Ben Mitchell <ben at mitchellfamily.com> wrote:
> You're on the right track, but off by a hair ;-)
>
> Turns out httpd is an Intel (64 bit) process
>
> Sooo...  I need to figure out how to get a 64-bit version of the .so
> built, when it's building only the 32-bit version by default.
>
> Any thoughts on that?
>
> And thanks.  I _never_ would've figured this one out on my own.
>
> -Ben
>
> On Oct 29, 2007, at 10:05 PM, Graham Dumpleton wrote:
>
> Okay, might now what the issue is now.
>
> What may be happening is that Apache server is running up in Rosetta
> (ie., PPC), and because the mod_wsgi/mod_python .so files are Intel
> only it isn't working.
>
> First step is to determine what Apache is running as. Think you can do
> this by running 'Activity Viewer' or whatever they now call it. Ensure
> that 'Kind' column is viewable and see what is against httpd
> processes. Will be PowerPC or Intel. If it shows PowerPC, that will be
> the problem.
>
> To fix I think you run Finder, select Go->Go To Folder and enter
> '/usr/sbin'. Then find 'httpd' and go File->GetInfo. From memory in
> there somewhere is a way of marking the process to run as Intel rather
> than PowerPC.
>
> The question is that if this is necessary, why it is running as
> PowerPC by default.
>
> Graham
>
> On 30/10/2007, Ben Mitchell <ben at mitchellfamily.com> wrote:
>
> Sorry.  Missed what you were asking for.  Looks like most of them
>
> have all
>
> the architectures, but the Mach-O bundle i386 seems to be the same
>
> for the
>
> wsgi one and the others.
>
>
>
>
>
>
>
> [Macintosh:~/Documents/Development] benha% file
>
> /usr/libexec/apache2/*.so
>
> /usr/libexec/apache2/libphp5.so:             Mach-O
>
> universal binary with 4 architectures
>
> /usr/libexec/apache2/libphp5.so (for architecture ppc7400): Mach-O
>
> bundle
>
> ppc
>
> /usr/libexec/apache2/libphp5.so (for architecture ppc64): Mach-O 64-
>
> bit
>
> bundle ppc64
>
> /usr/libexec/apache2/libphp5.so (for architecture i386): Mach-O
>
> bundle i386
>
> /usr/libexec/apache2/libphp5.so (for architecture x86_64): Mach-O 64-
>
> bit
>
> bundle x86_64
>
> /usr/libexec/apache2/mod_actions.so:         Mach-O
>
> universal binary with 4 architectures
>
> /usr/libexec/apache2/mod_actions.so (for architecture
>
> ppc7400): Mach-O bundle ppc
>
> /usr/libexec/apache2/mod_actions.so (for architecture
>
> ppc64): Mach-O 64-bit bundle ppc64
>
> /usr/libexec/apache2/mod_actions.so (for architecture
>
> i386): Mach-O bundle i386
>
> /usr/libexec/apache2/mod_actions.so (for architecture
>
> x86_64): Mach-O 64-bit bundle x86_64
>
> ...
>
>
>
>
>
>
>
>
>
>
>
>
>
> On Oct 29, 2007, at 9:47 PM, Graham Dumpleton wrote:
>
> Was there no other .so files besides mod_wsgi.so in:
>
>
>
>  /usr/libexec/apache2
>
>
>
> Was wanting to see what 'file' yielded on other .so files in that
>
> directory.
>
>
>
> if there is no other .so files, would suggest that they are static
>
> linking core Apache modules, which they haven't done in the past.
>
>
>
> Anyway, I will bring it all up on Apache modules-dev list in case
>
> others have heard about such issues.
>
>
>
> Graham
>
>
>
> On 30/10/2007, Ben Mitchell <ben at mitchellfamily.com> wrote:
>
>
>
> Looks ok to me, though we're way out of my depth at this point :-)
>
>
>
>
>
>
>
> [Macintosh:~/Documents/Development] benha% file
>
> /usr/sbin/httpd
>
> /usr/sbin/httpd: Mach-O universal binary with 4 architectures
>
> /usr/sbin/httpd (for architecture ppc7400): Mach-O executable ppc
>
> /usr/sbin/httpd (for architecture ppc64): Mach-O 64-bit executable
>
> ppc64
>
> /usr/sbin/httpd (for architecture i386): Mach-O executable i386
>
> /usr/sbin/httpd (for architecture x86_64): Mach-O 64-bit executable
>
> x86_64
>
> [Macintosh:~/Documents/Development] benha% file
>
> /usr/libexec/apache2/mod_wsgi.so
>
> /usr/libexec/apache2/mod_wsgi.so: Mach-O bundle i386
>
> [Macintosh:~/Documents/Development] benha%
>
>
>
>
>
>
>
>
>
> On Oct 29, 2007, at 9:35 PM, Graham Dumpleton wrote:
>
> One more and then I will have exhausted my ideas and may have to
>
> research elsewhere.
>
>
>
>  file /usr/sbin/httpd
>
>
>
> Change path if this isn't what Apache server executable is called.
>
>
>
>  file /usr/libexec/apache2/*.so
>
>
>
> This is to see what other Apache and other modules are compiled as.
>
> Ie., Intel only or dual architecture etc.
>
>
>
> Graham
>
>
>
> On 30/10/2007, Ben Mitchell <ben at mitchellfamily.com> wrote:
>
>
>
> [Macintosh:local/src/PyGreSQL-3.8.1] benha% otool -L
>
> /usr/libexec/apache2/mod_wsgi.so
>
> /usr/libexec/apache2/mod_wsgi.so:
>
> /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current
>
> version
>
> 111.0.0)
>
> /Library/Frameworks/Python.framework/Versions/2.5/Python
>
> (compatibility version 2.5.0, current version 2.5.0)
>
> /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current
>
> version
>
> 1.0.0)
>
> [Macintosh:local/src/PyGreSQL-3.8.1] benha%
>
>
>
>
>
>
>
>
>
> On Oct 29, 2007, at 9:18 PM, Graham Dumpleton wrote:
>
> How about:
>
>
>
>  otool -L /usr/libexec/apache2/mod_wsgi.so
>
>
>
> Should refer to standard Python framework.
>
>
>
> Graham
>
>
>
> On 30/10/2007, Ben Mitchell <ben at mitchellfamily.com> wrote:
>
>
>
> I started off yesterday doing an "Upgrade."  But I found enough
>
> weirdness
>
> that I did an "Archive and Install" tonight.  It's an intel MacBook
>
> Pro.
>
> ...
>
>
>
> [Message clipped]
>
>
>
>
>
>
>
>


More information about the Mod_python mailing list