Py2exe and WMI module

Tim Golden tim.golden at viacom-outdoor.co.uk
Mon Jan 26 11:53:12 EST 2004


>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>

Given a module, say, wmi_test.py, which imports the wmi module,
you can now run

c:\python23\python setup.py py2exe

in the usual way to create an exe.

After that, you're even more on your own than you were before.

TJG



________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________




More information about the Python-list mailing list