[mod_python] PIL not working in mod_python on macosx 10.5

Arnaud Delobelle delobelle at blueyonder.co.uk
Wed Nov 7 15:06:27 EST 2007


On 7 Nov 2007, at 08:38, Graham Dumpleton wrote:

> On 07/11/2007, Arnaud Delobelle <delobelle at blueyonder.co.uk> wrote:
>>
>> On 7 Nov 2007, at 00:59, Graham Dumpleton wrote:
>>>
>> [...]
>>> Post here what is output to the Apache error log file.
>>
>>
>> This is the tail of error_log:
>>
>>        File "/Users/arno/Sites/square.py", line 43, in <module>
>>                import _imaging
>>
>>        ImportError: 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
>> So this is as I suspected first.  But how is that as python is i386/
>> ppc and so is _imaging.so?
>
> Both Python framework and httpd on Leopard are x86_64 capable. Quoting
> from previous where this was already worked out:
>

I didn't realise this thanks.

> You just need to rebuild PIL, modifying the makefiles as necessary to
> ensure that it generates a full fat binary.
>
OK I've done this and it works now.  There aren't any makefiles in  
PIL, it's all done through a setup.py script.  If anyone is  
insterested, I used the following awful hack: after the lines

from distutils import sysconfig
from distutils.core import Extension, setup
from distutils.command.build_ext import build_ext

add the following lines

OrigExtension = Extension
def Extension(*args, **kwargs):
     extra_args = ['-arch', 'ppc', '-arch', 'ppc64', '-arch', 'i386',  
'-arch', 'x86_64']
     kwargs['extra_compile_args'] = extra_args +  
kwargs.get('extra_args', [])
     kwargs['extra_link_args'] = extra_args +  
kwargs.get('extra_link_args', [])
     return OrigExtension(*args, **kwargs)


Then every extension built in the script is built for all 4  
architectures.
[...]
> I do find it awfully strange that the Python framework is fully fat
> and the 'python' program isn't. Apple seems to have screwed up various
> things with Apache and Python. :-(
>

Yes

> Graham
>

Thanks again for your feedback and advice, even though this problem is  
not related to mod_python in the end.

-- 
Arnaud




More information about the Mod_python mailing list