views:

171

answers:

1

Hi,

I'm currently writing a small python app that embeds cherrypy and django using py2app. It worked well until I tried to include pyobjc in my project, since my app needed a small GUI (which consists of a small icon in the top menu bar + a drop down menu).

I can run my python script without any problem (I'm using python 2.6 with macports), but I can't launch the application bundle generated by py2app. A dialog box appears with the following message:

ImportError:
dlopen(/Users/denis/tlon/standalone/mac/dist/django_cherry.app/Contents/Resources/lib/python2.6/lib-dynload/CoreFoundation/_inlines.so, 2): no suitable image found.
Did find:
    /Users/denis/tlon/standalone/mac/dist/django_cherry.app/Contents/Resources/lib/python2.6/lib-dynload/CoreFoundation/_inlines.so: mach-o, but wrong architecture

I did a quick :

sudo port -u install py26-pyobjc +universal

but for some reason macports tries to build openssl, with which compilation fails each time. It seems the problem is related to zLib - this is what appears in the logs :

:info:build ld: warning: in /opt/local/lib/libz.dylib, file is not of required architecture

...And here is the output of file /opt/local/lib/libz.dylib :


    /opt/local/lib/libz.dylib: Mach-O universal binary with 2 architectures
    /opt/local/lib/libz.dylib (for architecture x86_64):    Mach-O 64-bit dynamically linked shared library x86_64
    /opt/local/lib/libz.dylib (for architecture i386):  Mach-O dynamically linked shared library i386

Nothing looks wrong to me.

I'm a bit stuck here. I don't even understand what openssl has to do with pyObjc, but it looks like I can't go anywhere if I don't manage to compile it. Macports really suck sometimes :/

EDIT I manage to fix Macports issue, but not py2app one :/

+1  A: 

I'm guessing it's because a required library is not in your library path, so the loader can't figure out where it is so it can link the symbols in. You should do one of two things:

  1. Add /opt/local/lib to your $LD_LIBRARY_PATH environment variable when launching the app; or
  2. Bundle the appropriate libraries with the .app file.
mipadi
Thanks. Actually I've finally managed to compile and get everything running.To fix the first 'wrong architecture' problem I've found a workaround by replacing the macports pyobjc libraries by the apple one, which comes pre-installed with the os and are compiled for different architectures (in /System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/PyObjC/)I have a bash script that copy everything in the right place just after the ".app" is built with py2app - it works fine this way.
Neewok