[Distutils] eggs and py2app/py2exe

Phillip J. Eby pje at telecommunity.com
Wed Jul 6 17:58:20 CEST 2005


At 10:30 AM 7/6/2005 -0400, Kevin Dangoor wrote:
>Let's say you've got some libraries installed as eggs. If you run
>py2app or py2exe on the application, it seems like you'd want the egg
>(or at least it's contents) to come along with the application. Or, at
>least, I'd prefer it for the eggs to come along with the app, rather
>than being downloaded via require.
>
>(For curiousity's sake, I just tried it and found that the contents of
>the eggs were left behind when I ran py2app. Not at all surprising,
>given that I don't think py2app or py2exe know about eggs yet...)
>
>Anyone have opinions on how a standalone app should look with eggs?

The egg runtime is designed to allow "baskets" - zip files containing 
multiple eggs - in order to support py2exe and similar scenarios.

Let's say you have two dependencies: foo 1.2 and bar 3.4.  Your 
py2exe-generated zipfile contents should look like this:

    some_main_module.py
    some_stdlibmodule.py
    ...etc.

    foo-1.2-py2.4-win32.egg/
        EGG-INFO/
            PKG-INFO
        some_foo_module.py
        ...etc.

    bar-3.4-py2.4-win32.egg/
        EGG-INFO/
            PKG-INFO
        some_bar_module.py
        ...etc.

In other words, you can zip up a bunch of directory eggs into a single 
zipfile, and the runtime will treat them as separate eggs.  Of course, 
'pkg_resources.py' needs to be among the modules placed directly in the 
zipfile, or else it won't be findable.

Another alternative that's possible is to just include all the modules and 
packages directly, copying EGG-INFO dirs to ProjectName.egg-info 
dirs.  This makes the packages discoverable with all their metadata, but 
doesn't provide any flexibility of activation.  However, for a 
py2exe/py2app scenario, you probably don't need that flexibility for 
anything you're hardwiring into the executable anyway.  The metadata is 
more useful on the build side, in that tools like py2exe and py2app could 
use setuptools' dependency info to assemble the application from the 
designated eggs, rather than trying to sniff out all the dependencies by 
introspection.



More information about the Distutils-SIG mailing list