py2exe, installer, pythoncom

Thomas Heller theller at python.net
Tue Jun 3 03:56:47 EDT 2003


[edited repost of a message I sent to the python-win32 list]

I was looking into improving support for win32com COM servers created
with py2exe, and came up with the following questions:

1. Pythoncom uses the '--unregister' command line flag, and doesn't
support a '--register' flag, registration is default.  Why is this,
instead of using the MS standard '/regserver' and '/unregserver' case
insensitive flags?  And why is the localserver registered with a
/Automate flag, as I understand it localservers receive a '/Embedding'
command line flag automatically when started by com (at least this is
the result of my experiments on WinXP Pro).

2. Pythoncom uses a trivial approach looking for these command line
flags, any unknown flags are simply ignored. Since it is impossible with
the getopt module to parse windows style command lines correctly, I've
written a simple w_getopt function which is able to do this. It is
online at http://tinyurl.com/d21n.

3. The win32com.server.register module contains special stuff for
McMillan installer, and maybe also freeze.  I suggest to invent a
function like this (which can also be useful to the NT service module)
to decide if the server must be started by python.exe (or pythonw.exe),
or is contained in an executable built with py2exe, installer, cx_freeze
or Python's freeze tool:

def main_is_frozen():
  import imp
  return (hasattr(sys, "frozen") # mcmillan installer
          or hasattr(sys, "importers") # py2exe
          or imp.is_frozen("__main__")) # freeze, cx_freeze

Maybe a similar api can be provided for frozen inproc servers, which
currently are only possible with mcmillan.

4. Why is win32com.server.register.UseCommandLine only used for
registration and unregistration? Wouldn't it make more sense to use it
also for starting the localserver process, provided that /Embedding is
used?  The advantage would be that UseCommandLine gets the COM classes
to expose as arguments, and doesn't have to read registry to find them.

Thomas




More information about the Python-list mailing list