Use attribute windows or console of method setup to create a com exe server. Unlike the case with win32com, with ctypes.com only a exe server will be created. Also see: Py2exeAndWin32com & Py2exeAndCtypesComDllServer

You can define and instantiate a Target class to explicitly 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
   2 # server using ctypes.com.  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 .exe file 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 filename for ctypes.com exe server
  26     script = "dir\my_com_server.py",
  27     # dest_base specifies basename of the exe file (should match setup name)
  28     dest_base = "my_com_server",
  29     # the following line embeds the typelib within the exe
  30     other_resources = [("TYPELIB", 1, open(r"dir\my_com_server.tlb", "rb").read())],
  31     # we only want the local (exe) server
  32     create_dll = False
  33     )
  34 
  35 setup(
  36     name="my_com_server",
  37     # the following two parameters embed support files within exe file
  38     options={"py2exe": {"bundle_files": 1, }},
  39     zipfile=None,
  40     version="0.0.1",
  41     description="my com server",
  42     # author, maintainer, contact go here:
  43     author="First Last",
  44     author_email="some_name@some_company.com",
  45     packages=["dir"],
  46     windows=[my_com_server_target]
  47     )

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