python封装dll_Python dll打包 | 学步园

原文地址http://www.py2exe.org/index.cgi/Py2exeAndCtypesComDllServer# This is the distutils script for creating a Python-based com dll

# server using ctypes.com. This script should be run like this:

#

# % python setup.py py2exe

#

# After you run this (from this directory) you will find two directories here:

# "build" and "dist". The .dll file in dist is what you are looking for.

##############################################################################

from distutils.core import setup

import py2exe

import sys

class Target:

def __init__(self, **kw):

self.__dict__.update(kw)

# for the version info resources (Properties -- Version)

self.version = "0.0.1"

self.company_name = "my company"

self.copyright = "© 2006, my company"

self.name = "my com server name"

my_com_server_target = Target(

description = "my com server",

# use module name for ctypes.com dll server

modules = ["dir.my_com_server"],

# the following line embeds the typelib within the dll

other_resources = [("TYPELIB", 1, open(r"dir\my_com_server.tlb", "rb").read())],

# we only want the inproc (dll) server

create_exe = False

)

setup(

name="my_com_server",

# the following two parameters embed support files within dll file

options={"py2exe": {"bundle_files": 1, }},

zipfile=None,

version="0.0.1",

description="my com server",

# author, maintainer, contact go here:

author="First Last",

author_email="some_name@some_company.com",

packages=["dir"],

ctypes_com_server=[my_com_server_target]

)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值