[python-win32] Re: genpy and py2exe

Thomas Heller theller at python.net
Tue May 13 17:47:20 EDT 2003


"Erignac, Charles A" <charles.a.erignac at boeing.com> writes:

> I am trying to use the genpy capability from within the confines of
> Python program packaged by py2exe. This program and its dependent
> modules are packaged in a single executable zip archive. When the
> executable starts the support code of py2exe substitutes the default
> module importer, which looks for modules in the file system, with an
> importer that looks for modules directly in the archive.

> For some reason I cannot pre-package my COM wrappers. Unfortunately
> the py2exe is incompatible with generating wrappers on demand. Genpy
> will create the wrappers but the Python environment cannot load them.

> I have not looked deep enough yet in the importer mechanism to know
> whether one could add a secondary importer to look for the modules
> elsewhere.

If I understand correctly, you are running makepy (or genpy) from within
the packaged program?

If this is so, there are 2 problems:
- where will the generated files be created, and how can you determine
  this directory,
- how do you import these files.

For the first problem, you should read the win32all code, and experiment
with the exe.
Foe the second problem, IIRC, you don't need a custom importer
(probably). The exe-file still can import from the file system, just add
the directory to sys.path.

> Suggestions are welcome.
> Best regards,
> Charles

Thomas




More information about the Python-win32 mailing list