[Twisted-Python] Trying to get twisted.protocols.amp to work with py2app...

Nathan nathan.stocks at gmail.com
Wed Mar 5 11:41:17 EST 2008


On Tue, Mar 4, 2008 at 5:39 PM, Phil Christensen <phil at bubblehouse.org> wrote:
>
> On Mar 4, 2008, at 6:50 PM, Nathan wrote:
>
>  >>> Maybe when you actually run the .app it's finding the system-
>  >>> installed
>  >>> version of Twisted?
>  >>>
>  >> And the canonical way to locate that problem would be to add
>  >> something
>  >>  like:
>  >>
>  >>  import twisted.protocols
>  >>  print twisted.protocols.__file__
>  >>
>  >>  to your app, to see from where the twisted package is coming.
>  >>
>  >
>  > Now we're getting somewhere!  Yes, even though py2app seems to be
>  > pulling in my Twisted 2.5 from /Library/Python/2.5/site-packages when
>  > the app is built, when the app is actually run it's finding the
>  > Leopard-default-installed Twisted 2.4 instead:
>  >
>  > /System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/
>  > python/twisted/protocols/__init__.pyc
>  >
>  > So, the next logical question would be:  How do I get my script inside
>  > my .app to consider the libraries inside the .app first?  You'd think
>  > that py2app would already be taking care of that...
>
>  This is a little inelegant (maybe even a lot inelegant), but when
>  i've had issues with the system path that I couldn't fix (because I
>  didn't have root, or was just in a hurry), I've just manipulated
>  sys.path at the start of my code before I've imported any modules.

I'm fine with doing that, but how do you find the path you need to
insert into sys.path?  The amp.py that it includes is inside
MyApp.app/Contents/Resources/lib/python2.5/site-packages.zip -- a ZIP
file!  Does sys.path support zip files??
sys.path.insert(0,'../Resources/lib/python/2.5/site-packages.zip/twisted')
??

~ Nathan




More information about the Twisted-Python mailing list