From: Fox, M. K <mic...@bo...> - 2006-09-21 19:35:28
|
First, Mark, you are correct that I meant to say I'm now trying solution 1, not solution 2. Second, you are correct that my problem was a TLB that I was directly requesting. I stumbled across the solution while hacking at makepy, accidentally causing it to tell me which TLB it was unable to load. Now I can freeze and distribute applications that interface with CATIA ! This is awesome ! This is off-topic here, but for what it's worth this is what I did to makepy.py: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D def GenerateFromTypeLibSpec(snip): ...snip... if type(typelibInfo)=3D=3Dtype(()): # Tuple typelibCLSID, lcid, major, minor =3D typelibInfo #### I added this try-block around the existing code # It causes py2exe to spit out an error message telling me which typelib it couldn't find. # Then I can remove that TLB from the list in setup.py try: tlb =3D pythoncom.LoadRegTypeLib(typelibCLSID, major, minor, lcid) spec =3D selecttlb.TypelibSpec(typelibCLSID, lcid, major, minor) spec.FromTypelib(tlb, str(typelibCLSID)) typelibs =3D [(tlb, spec)] except: typelibs =3D [] #### new line =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Then, when I ran py2exe and it tried to import the gen_py modules it threw the following error: >>>>>>>>>>>>>>>> creating C:\cygwin\usr\project\CSICM\build\bdist.win32\winexe\temp\win32com\gen_p y Traceback (most recent call last): File "setup.py", line 122, in ? packages =3D ['kbe_catia'] File "C:\Python24\Lib\distutils\core.py", line 149, in setup dist.run_commands() File "C:\Python24\Lib\distutils\dist.py", line 946, in run_commands self.run_command(cmd) File "C:\Python24\Lib\distutils\dist.py", line 966, in run_command cmd_obj.run() File "C:\Python24\Lib\site-packages\py2exe\build_exe.py", line 218, in run self._run() File "C:\Python24\Lib\site-packages\py2exe\build_exe.py", line 249, in _run self.typelibs) File "C:\Python24\Lib\site-packages\py2exe\build_exe.py", line 1497, in collect_win32com_genpy mod =3D gencache.GetModuleForTypelib(*info) File "C:\Python24\lib\site-packages\win32com\client\gencache.py", line 258, in GetModuleForTypelib mod =3D _GetModule(modName) File "C:\Python24\lib\site-packages\win32com\client\gencache.py", line 629, in _GetModule mod =3D __import__(mod_name) ImportError: No module named D711238C-A187-4C7D-9F42-88AF6F0F0D2Ex0x0x0 >>>>>>>>>>>>>>>>> Previously, py2exe would run without complaint, then would fail at runtime. But the last line above told me what the problem really was. I went into my setup.py and commented out that one typelib (which=20 luckily isn't one I need) then reran py2exe, and after that the frozen executeable didn't fail at run time. -----Original Message----- From: Mark Hammond [mailto:mha...@sk...]=20 Sent: Thursday, September 21, 2006 1:04 AM To: Fox, Michael K; py2...@li... Subject: RE: [Py2exe-users] catia typelib problem > I've seen the page in the wiki=20 > <http://www.py2exe.org/index.cgi/IncludingTypelibs> > about this Interestingly, the footnote of solution 2 appears incorrect. It asserts solution 2 itself doesn't work - but I believe it should work fine. It's is unsuitable for some applications though, but is regardless of py2exe. Also, I'm a little confused about solution 3. Solution 1 does *not* require the typelibs to be installed on the target machine - that is the point. It is possible, for example, to have Office installed, but not all the typelibs necessary to implement a plugin. That option should mean Python never needs to load any typelibs on the target machine (and therefore obviously avoids depending on installed typelibs). Regarding newer versions of the typelib, that is only a problem if the vendor actually breaks old interfaces - but either way, it should be possible to include multiple versions of the same typelib. OTOH, a problem spambayes is facing is that *developers* may not always have all typelibs installed. Eg, spambayes ships with files generated from the Office2k typelibs (as that still works with newer versions of office) - but many people only have later versions installed. If spambayes ships with only the newer versions, it will no longer work for users of Office2k. We need a strategy that allows the generated files to be checked into source control, but still be recognised by py2exe. I really need to document that better, with examples. > Now I'm trying solution 2. Did you mean solution 1? Solution 2 does not involve py2exe options. > CATIA has 102 typelibs so I pasted them all into the setup.py file: > options =3D {"py2exe": {"typelibs": Ack - 102! That is amazing. > But then when I run py2exe I get the following error message: > C:\cygwin\usr\project\CSICM>python setup.py py2exe > running py2exe > running build_py > *** generate typelib stubs *** > creating > C:\cygwin\usr\project\CSICM\build\bdist.win32\winexe\temp\win32com > creating > C:\cygwin\usr\project\CSICM\build\bdist.win32\winexe\temp\win3 > 2com\gen_p > y > Traceback (most recent call last): > File "setup.py", line 121, in ? > packages =3D ['kbe_catia'] > File "C:\Python24\Lib\distutils\core.py", line 149, in setup > dist.run_commands() > File "C:\Python24\Lib\distutils\dist.py", line 946, in run_commands > self.run_command(cmd) > File "C:\Python24\Lib\distutils\dist.py", line 966, in run_command > cmd_obj.run() > File "C:\Python24\Lib\site-packages\py2exe\build_exe.py", line 218,=20 > in run > self._run() > File "C:\Python24\Lib\site-packages\py2exe\build_exe.py", line 249,=20 > in _run > self.typelibs) > File "C:\Python24\Lib\site-packages\py2exe\build_exe.py", line > 1495, in collect_win32com_genpy > makepy.GenerateFromTypeLibSpec(info, bForDemand =3D False) > File > "C:\Python24\lib\site-packages\win32com\client\makepy.py", > line 194, in > GenerateFromTypeLibSpec > tlb =3D pythoncom.LoadRegTypeLib(typelibCLSID, major, minor, > lcid) > pywintypes.com_error: (-2147312566, 'Error loading type=20 > library/DLL.', None, None) >=20 > I googled for this error message and found this=20 > <http://mail.python.org/pipermail/python-win32/2004-September.txt> in=20 > which Mark Hammond states "typelibs can have references to other=20 > typelibs - loading one of these other references is what is failing." > That was back in September, 2004. Has any solution been=20 > found for this > problem ? The problem you reference has been fixed - but I don't think it applies here. The traceback indicates that a typelib you directly requested - so one of the typelibs you asked for isn't installed on your machine. Mark |