I'm trying to find a way to force py2exe to include specific modules and dll's in a single-file executable.

In my application, I'm importing modules based on information loaded from an XML file at runtime.  I have something like this:

exec "import " + modulename

where modulename is a string that's been loaded from the XML file.

Clearly, py2exe has no way of knowing to include the modules in the executable, but I know that they're all in the same directory (which I add to sys.path at runtime).

I've tried adding that directory to sys.path in setup.py, and using the "includes" option to specify the names of the modules, but for some strange reason the use of "includes" is preventing a dll ( OgreMain.dll) from being found.  That strikes me as very odd, but there you have it.

If I were using a zipfile (e.g. library.zip) it would lbe easy -- I would just add some code to setup.py to use the zipfile module to append the modules I'll be need ing at runtime.  However, since I'm building an exe, that isn't an option.

A related question... some of the dll's I load use LoadLibrary() to load other dll's.  Again, py2exe has no way to identify that dependency, so I'm looking for a way to force specifc dll's to be included in the exe file.

I've been wrestling with this for a couple of days now, so any help would be much appreciated.


   Bernie Roehl
   Software Consultant
   Mail: broehl@gmail.com
   Voice:  (519) 577-8494