[Distutils] py2exe and eggs

Jay Parlar parlar at gmail.com
Tue Aug 16 18:23:47 CEST 2005

I followed the steps, but I believe I'm missing something basic about
eggs in general.

The py2exe result now has the two egg files in it, but the only way
I'm actually able to import them is by doing:


at the top of my main .py file. That doesn't seem like the right thing to do...

pkg_resources.find_distributions(".") can find the distibutions fine,
but how do I tell the runtime that it should look on "." for eggs,
without having to append to sys.path?

Jay P.

On 8/16/05, Kevin Dangoor <dangoor at gmail.com> wrote:
> On 8/16/05, Jay Parlar <parlar at gmail.com> wrote:
> > Any solutions to this? I don't mind a solution that requires me to add
> > something to setup.py that can automatically find any of the eggs I
> > use, but I'd really like to avoid adding something to setup.py for
> > *each* egg I use.
> My solution to this is ugly, but it's not much code (about 50 lines of
> trivial stuff) and didn't require delving into py2exe itself.
> py2exe really tries to minimize your distribution size and get rid of
> all unused modules. My method takes the eggs wholesale, so it's not
> quite as space efficient.
> Here's what I do:
> 1) get the list of Distributions using pkg_resources.require(), as
> Phillip suggests
> 2) keep track of the packages in the egg (using the egg's
> metadata.get_metadata_lines('top_level.txt'))
> 3) if the egg is pointing to a directory, add all of the files there
> to data_files. If it's a zipped up egg, just add the .egg file to
> data_files
> 4) finally, after building the exe, I create a new library.zip file
> that doesn't contain the packages found in step 2. (So, it's not a
> minimal set of packages and modules, but it at least isn't duplicating
> packages!)
> It's not pretty, but it does work. And, in my case, this process works
> with both py2exe and py2app and was less work than modifying both of
> those packages to do something with the eggs.
> Kevin

More information about the Distutils-SIG mailing list