[python-win32] Re: genpy and py2exe

Erignac, Charles A charles.a.erignac at boeing.com
Tue May 13 12:16:29 EDT 2003


I set  win32com.__gen_path__ to 'C:\Temp\gen_py' through the GenPath registry key. Also made sure that the path was in sys.path. This setup works fine from python.exe. Unfortunately fron the py2exe package I still get an ImportError when loading a wrapper :(.
Charles

-----Original Message-----
From: Thomas Heller [mailto:theller at python.net]
Sent: Tuesday, May 13, 2003 9:36 AM
To: python-win32 at python.org
Subject: [python-win32] Re: genpy and py2exe


"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


_______________________________________________
Python-win32 mailing list
Python-win32 at python.org
http://mail.python.org/mailman/listinfo/python-win32



More information about the Python-win32 mailing list