COM Server and Py2EXE
Gregory P. Smith
greg at electricrain.com
Wed Sep 5 00:36:10 EDT 2001
On Tue, Sep 04, 2001 at 05:55:47PM +0000, Matthew Turk wrote:
> Hi there! Word on the street is that py2exe cannot currently handle
> COM servers. Anybody out there 'in the know' that might happen to
> know if it's a goal, or a feasible goal, or if I should just get on
> with my life? I couldn't find any mailing lists for py2exe (but, then
> again, I might have just missed them) or I'd check them first.
>
> Thanks!
It handles COM servers just fine. I use it to package a local server
style COM server. Here's the relevant portion of the main code that
gets py2exe'd:
import pythoncom
# tell the win32 COM registering/unregistering code that we're inside
# of an EXE
pythoncom.frozen = 1
# Disable linecache.getline() which is called by
# traceback.extract_stack() when an exception occurs to try and read
# the filenames embedded in the packaged python code. This is really
# annoying on windows when the d: or e: on our build box refers to
# someone elses removable or network drive so the getline() call
# causes it to ask them to insert a disk in that drive.
import linecache
def fake_getline(filename, lineno):
return ''
linecache.orig_getline = linecache.getline
linecache.getline = fake_getline
if ('--register' in sys.argv) or ('--unregister' in sys.argv) or ('--debug' in sys.argv):
#print "doing COM server registration stuff..."
import AgentCOMServer
AgentCOMServer._handle_com_registration()
elif ('--standalone' in sys.argv):
import Agent
Agent.run()
else:
#print "running win32com.server.localserver stuff..."
import win32com.server.localserver
win32com.server.localserver.main()
More information about the Python-list
mailing list