[Pythonmac-SIG] django webapp using CoreGraphics complains about "wrong architecture"

Geert Dekkers geert at nznl.com
Sun Sep 13 16:58:31 CEST 2009


Hi there,

I have a couple of webapps in django designed to run on xserves. When  
I started the apps last year, I found and used the CoreGraphics  
bindings for python as described at http://developer.apple.com/graphicsimaging/pythonandquartz.html 
  and some other places. Actually, this was the reason I took up  
python in the first place (which was most certainly no mistake!).

But -- as the xserve runs Apache as Intel64, I had to recompile stuff  
for Apache. Not a problem. The CoreGraphics bindings are used as a  
standalone cli app within my webapp, so no problem with those either,  
as long as Apache doesn't want to run them.

A couple of things have changed in the last year, though. For  
starters, it seems the CoreGraphics bindings are going nowhere, PyObjC  
seems to be the way forward. A rather steep learning curve, but so be  
it. And then I have now found need for Apache to use CoreGraphics. I  
know I have alternatives (ReportLab for PDF's PIL for bitmaps) but my  
stance is that my platform of choice has perfectly good support for  
these formats, (and does blazingly fast conversions to boot!) so why  
go looking for others?

The problem is of course that I need to coax PyObjC to be run by 64  
bit Apache. I read about the ability for PyObjC to run in 64-bit mode  
at http://pyobjc.sourceforge.net/documentation/pyobjc-core/news.html.  
I don't know where to find out if my python is built with the required  
MACOSX_DEPLOYMENT_TARGET=10.5, but I would think so (as I'm running  
10.5.8). (And you must realise I'm no hard-core programmer -- I learn  
as I go -- make heaps of mistakes doing so)

I did try a few tricks to get pyobjc to build as full fat binary (that  
is -arch ppc -arch i386 -arch ppc64 -arch x86_64) but so far no joy.

(Actually one of the results was quite discerning: an example "ld  
warning: in build/temp.macosx-10.5-i386-2.5/Modules/_sortandmap.o,  
missing required architecture ppc64 in file
ld warning: in build/temp.macosx-10.5-i386-2.5/Modules/_sortandmap.o,  
missing required architecture x86_64 in file")

And I'm wondering if this is at all necessary. Because -- why can  
Apache run PIL??? -- the .so files are also not full fat, but you can  
indeed do "import Image"

dekkers-2:~ geert$ file /Library/Python/2.5/site-packages/PIL/ 
_imaging.so
/Library/Python/2.5/site-packages/PIL/_imaging.so: Mach-O universal  
binary with 2 architectures
/Library/Python/2.5/site-packages/PIL/_imaging.so (for architecture  
i386):	Mach-O bundle i386
/Library/Python/2.5/site-packages/PIL/_imaging.so (for architecture  
ppc7400):	Mach-O bundle ppc

But if you do "import _imaging", Apache gives you: "Could not import  
ccnet.views. Error was: dlopen(/Library/Python/2.5/site-packages/PIL/ 
_imaging.so, 2): no suitable image found. Did find: /Library/Python/ 
2.5/site-packages/PIL/_imaging.so: no matching architecture in  
universal wrapper"

Does anyone have any experience using cocoa libs in a webapp like I  
want to do?  I really would like to get this going. Tips, tricks &  
Enlightment would be very welcome!

Geert



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pythonmac-sig/attachments/20090913/6944aa70/attachment.htm>


More information about the Pythonmac-SIG mailing list