I have a setup file for an app that I change and rebuild from time to
time, that uses a typelib whose GUID also changes from time to time.
I'd rather not have to manually update the setup file to paste the GUID
into it, so I've been trying ways to generate the needed info in the
setup file.
If I know the path to the DLL, I can do this successfully using
pythoncom.LoadTypeLib. However, I don't want to build in a dependency
on the path, either.
My latest attempt is to use gencache.GetClassForProgID, as follows:
> cls = gencache.GetClassForProgID('MyLib.someClass')
> # Get the display name of the class, which includes the typelib info
> s = str(cls)
> # Now parse out the GUID, major, minor, and LCID from the lib name
> m = re.match('win32com.gen_py.([^x]+)x(.)x(.)x(.)', s)
> LibTypeInfo = ('{'+m.group(1)+'}', int(m.group(2)), int(m.group(3)), int(m.group(4)))
... and paste the string into the "typelibs" list.
This succeeds in generating the right stuff, but the setup fails.
Essentially, the build\bdist.win32\winexe\temp\win32com\gen_py folder
gets a single file version of the library, rather than the folder with
individual files for the classes. Then py2exe goes looking for one of
the class files and fails. I'm assuming that somehow the gencache call
is fouling things up. (If I comment the above out, and manually paste
the generated string in, it builds without a problem.)
Anyone have a suggestion?
Thanks,
--
Don Dwiggins
Advanced Publishing Technology
|