[Posted and mailed]
> I tried to write a python com object, it's really
> easy and it works, now i'm wondering if it is possible
> to distribute it without the whole installation of python
> and the com extensions.
> For exe i found the freeze tool which works fine,
> for a com object i tried but it does not work in fact
> i think that the pythoncom.dll looks for some modules and
> dlls of the python installation (considering the pythonpath
> set in the registry) is this true? or anyway
> is it possible to define a minimal subset to distribute?
It is possible to use py2exe to build COM servers,
although currently only exe-servers are possible.
The command-line handling has to be fixed to take care of
the special environment in which the built exe is run.
If you want to try it, the following sample may give you
a start.
Regards,
Thomas
# comserver.py
import sys
import pythoncom
# if running in the built executable, module sys
# has an 'importers' attribute.
if hasattr(sys, 'importers'):
pythoncom.frozen = 1
class HelloWorld:
_reg_clsctx_ = pythoncom.CLSCTX_LOCAL_SERVER
_reg_class_spec_ = "__main__.HelloWorld"
_reg_clsid_ = "{B83DD222-7750-413D-A9AD-01B37021B24B}"
_reg_desc_ = "Python Test COM Server"
_reg_progid_ = "Python.TestServer"
_public_methods_ = ['Hello']
_public_attrs_ = ['softspace', 'noCalls']
_readonly_attrs_ = ['noCalls']
def __init__(self):
self.softspace = 1
self.noCalls = 0
# __init__()
def Hello(self, who):
self.noCalls = self.noCalls + 1
# insert "softspace" number of spaces
return "Hello" + " " * self.softspace + str(who)
if __name__ == '__main__':
if hasattr(sys, 'importers'):
if '--register' in sys.argv[1:] \
or '--unregister' in sys.argv[1:]:
import win32com.server.register
win32com.server.register.UseCommandLine(HelloWorld)
else:
from win32com.server import localserver
localserver.main()
else:
import win32com.server.register
win32com.server.register.UseCommandLine(HelloWorld)
_______________________________________________
ActivePython mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/activepython