Use attribute com_server of method setup to create a com exe/dll server. By default, both an exe and a dll com server get generated. The following two pages show how to do the same thing using ctypes.com: Py2exeAndCtypesComExeServer & Py2exeAndCtypesComDllServer

You can define and instantiate a Target class to explicitly state whether you want an exe or dll com server (or both) and to add version info resources that get attached to the file as metadata.

file setup.py would look something like this:

   1 # This is the distutils script for creating a Python-based com (exe or dll)
   2 # server using win32com.  This script should be run like this:
   3 #
   4 #  % python setup.py py2exe
   5 #
   6 # After you run this (from this directory) you will find two directories here:
   7 # "build" and "dist".  The .dll or .exe in dist is what you are looking for.
   8 ##############################################################################
   9 
  10 from distutils.core import setup
  11 import py2exe
  12 import sys
  13 
  14 class Target:
  15     def __init__(self, **kw):
  16         self.__dict__.update(kw)
  17         # for the version info resources (Properties -- Version)
  18         self.version = "0.0.1"
  19         self.company_name = "my company"
  20         self.copyright = "© 2006, my company"
  21         self.name = "my com server name"
  22 
  23 my_com_server_target = Target(
  24     description = "my com server",
  25     # use module name for win32com exe/dll server
  26     modules = ["dir.my_com_server"],
  27     # specify which type of com server you want (exe and/or dll)
  28     create_exe = True,
  29     create_dll = False
  30     )
  31 
  32 setup(
  33     name="my_com_server",
  34     # the following two parameters embed support files within exe/dll file
  35     options={"py2exe": {"bundle_files": 1, }},
  36     zipfile=None,
  37     version="0.0.1",
  38     description="my com server",
  39     # author, maintainer, contact go here:
  40     author="First Last",
  41     author_email="some_name@some_company.com",
  42     packages=["dir"],
  43     com_server=[my_com_server_target]
  44     )

Py2exeAndWin32com (last edited 2008-07-08 11:27:43 by localhost)