Py2exe and WMI module

Thomas Heller theller at python.net
Tue Jan 27 03:16:05 EST 2004


Tim Golden <tim.golden at viacom-outdoor.co.uk> writes:

>>From: nekiv at start.no [mailto:nekiv at start.no]
>>
>>I'm having a problem when I try to make a standalone installation of a
>>Python program using Tim Goldens WMI-module.  The py2exe produce the
>>exe-file as expected, but it fails to execute.
>
> Well, I've tried to play with wmi-py2exe myself for the first
> time, with mixed results. If I understand the idea, what you
> do is this:
>
> Use the makepy generator to generate gen_py support for the
> Microsoft WMI 1.1 Scripting Library. This will result in a
> proxy module in %TEMP%\gen_py\2.3 (for recent win32all releases)
> called something like:
>
> 565783C6-CB41-11D1-8B02-00600806D9B6x0x1x1.py
>
> Note the x0x1x1 at the end.
>
> You then need a setup script such as this one:
>
> <setup.py>
> from distutils.core import setup
> import py2exe
>       
> setup (
>   console=["wmi_test.py"],
>   options = {
>     "py2exe": {
>       "typelibs": [('{565783C6-CB41-11D1-8B02-00600806D9B6}', 0, 1, 1)]
>     }
>   }
> )
> </setup.py>
>
> That "typelibs" line is made up from the proxy string 
> effectively split like this:
>
> "565783C6-CB41-11D1-8B02-00600806D9B6x0x1x1".split ("x")
>
> It's not exactly that, but you can work it out for yourself. In
> fact, the first bit is the CLSID, and the others are the LCID,
> major and minor numbers from within
> 565783C6-CB41-11D1-8B02-00600806D9B6x0x1x1.py
>
> <... snipped from Python proxy module ...>
>
> CLSID = IID('{565783C6-CB41-11D1-8B02-00600806D9B6}')
> MajorVersion = 1
> MinorVersion = 1
> LibraryFlags = 8
> LCID = 0x0
>
> </snip>

I think the 'official' way is to run makepy with the '-i' flag, then it
prints out this:

c:\>\python23\lib\site-packages\win32com\client\makepy.py -i
Microsoft WMI Scripting V1.2 Library
 {565783C6-CB41-11D1-8B02-00600806D9B6}, lcid=0, major=1, minor=2
 >>> # Use these commands in Python code to auto generate .py support
 >>> from win32com.client import gencache
 >>> gencache.EnsureModule('{565783C6-CB41-11D1-8B02-00600806D9B6}', 0, 1, 2)

Thomas



More information about the Python-list mailing list