[Distutils] py2exe and eggs

Thomas Heller theller at python.net
Fri Aug 19 21:40:34 CEST 2005

"Phillip J. Eby" <pje at telecommunity.com> writes:

> At 12:20 PM 8/19/2005 -0400, Jay Parlar wrote:
>>Sorry to relaunch this topic, but I continue to have general problems
>>with eggs and py2exe.
> I guess I'll add it to my list to see if I can create a py2exe wrapper for 
> setuptools.  Or, since Thomas is now playing with setuptools also, perhaps 
> he, Kevin, and I can work something out to make py2exe work as a setuptools 
> extension.  Since setuptools provides hooks for such extensions to add 
> setup() keywords and new commands, maybe we can get py2exe hooked in such 
> that it just adds the required eggs to the zipfile in "basket" mode, and 
> doesn't bother tracking imports to packages found in eggs.  (Except maybe 
> for pkg_resources, which it should just always include in the zipfile.)

Not sure if I can find the time for this - and I'm currently not using
eggs myself.

I would hope that py2exe works together with directory eggs (is that the
name?) but not zip-eggs.

py2exe uses modulefinder to find dependencies.  Modulefinder scans the
bytecode of scripts and modules for import statements, then uses the imp
module to locate the dependencies. Since imp does not find modules and
packages in zip.files, all hope is off for zip-eggs.

I think a workaround could be to let py2exe run do its work normally,
and then add the zipped egg files (if you need them) to the dist folder
manually or per setup script (as data-files, maybe).  Before that you
should in the main script add the eggs filenames to sys.path of the
frozen exeutable, maybe that should work.

Still, you have to track the dependencies of the eggs themselves
manually, and pass them to py2exe.


More information about the Distutils-SIG mailing list