Roman Yakovenko schrieb:
> I am trying to generate module to custom directory and the process
> fails with next error:
>
> # Generating comtypes.gen._106173A0_0173_4E5C_84E7_E915422BE997_0_2_0
> # Generating comtypes.gen._00020430_0000_0000_C000_000000000046_0_2_0
> Traceback (most recent call last):
> File "pdb_reader.py", line 12, in <module>
> print comtypes.client.GetModule( r'D:\Program Files\Microsoft
> Visual Studio .NET 2003\Visual Studio SDKs\DIA SDK\bin\msdia71.dll' )
> File "e:\python25\Lib\site-packages\comtypes\client\_generate.py",
> line 100, in GetModule
> is_current, mod = _CreateWrapper(tlib, pathname)
> File "e:\python25\Lib\site-packages\comtypes\client\_generate.py",
> line 206, in _CreateWrapper
> generate_module(tlib, ofi, pathname)
> File "e:\python25\Lib\site-packages\comtypes\tools\tlbparser.py",
> line 704, in generate_module
> gen.generate_code(items.values(), filename=pathname)
> File "e:\Python25\Lib\site-packages\comtypes\tools\codegenerator.py",
> line 239, in generate_code
> self.generate_all(sorted(items, self.cmpitems))
> File "e:\Python25\Lib\site-packages\comtypes\tools\codegenerator.py",
> line 181, in generate_all
> self.generate(item)
> File "e:\Python25\Lib\site-packages\comtypes\tools\codegenerator.py",
> line 177, in generate
> mth(item)
> File "e:\Python25\Lib\site-packages\comtypes\tools\codegenerator.py",
> line 616, in External
> comtypes.client.GetModule(ext.tlib)
> File "e:\python25\Lib\site-packages\comtypes\client\_generate.py",
> line 100, in GetModule
> is_current, mod = _CreateWrapper(tlib, pathname)
> File "e:\python25\Lib\site-packages\comtypes\client\_generate.py",
> line 218, in _CreateWrapper
> mod = _my_import(fullname)
> File "e:\python25\Lib\site-packages\comtypes\client\_generate.py",
> line 14, in _my_import
> return __import__(fullname, globals(), locals(), ['DUMMY'])
> ImportError: No module named _00020430_0000_0000_C000_000000000046_0_2_0
>
> Here is the relevant source code:
>
> import os
> import sys
> import comtypes
> import comtypes.client
>
> gen_dir = r'D:\dev\xyz'
>
> sys.path.append( gen_dir )
>
> comtypes.client.gen_dir = gen_dir
> print comtypes.client.GetModule( r'D:\Program Files\Microsoft Visual
> Studio .NET 2003\Visual Studio SDKs\DIA SDK\bin\msdia71.dll' )
>
> Thanks
>
Here is a fix for this problem:
Index: comtypes/client/_generate.py
===================================================================
--- comtypes/client/_generate.py (revision 59545)
+++ comtypes/client/_generate.py (working copy)
@@ -11,6 +11,10 @@
def _my_import(fullname):
# helper function to import dotted modules
+ import comtypes.gen
+ if comtypes.client.gen_dir \
+ and comtypes.client.gen_dir not in comtypes.gen.__path__:
+ comtypes.gen.__path__.append(comtypes.client.gen_dir)
return __import__(fullname, globals(), locals(), ['DUMMY'])
def _name_module(tlib):
Thanks,
Thomas
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
comtypes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/comtypes-users