forked from enthought/comtypes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
170 lines (137 loc) · 4.91 KB
/
setup.py
File metadata and controls
170 lines (137 loc) · 4.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
r"""
comtypes
--------
**comtypes** is a lightweight Python COM package, based on the ctypes_
FFI library, in less than 10000 lines of code (not counting the
tests).
**comtypes** allows to define, call, and implement custom and
dispatch-based COM interfaces in pure Python. It works on Windows,
64-bit Windows, and Windows CE.
Documentation:
http://starship.python.net/crew/theller/comtypes/
`Mercurial repository
<https://sourceforge.net/p/comtypes/code/ci/default/tree/>`_
Mailing list:
http://gmane.org/info.php?group=gmane.comp.python.comtypes.user
https://lists.sourceforge.net/lists/listinfo/comtypes-users/
Download:
Releases can be downloaded in the PyPI page:
https://pypi.python.org/pypi/comtypes
.. _ctypes: http://docs.python.org/lib/module-ctypes.html
"""
import sys
import os
import ctypes
from distutils.core import Command
from setuptools import setup
try:
from distutils.command.build_py import build_py_2to3 as build_py
except ImportError:
from distutils.command.build_py import build_py
class test(Command):
# Original version of this class posted
# by Berthold Hoellmann to distutils-sig@python.org
description = "run tests"
user_options = [
('tests=', 't',
"comma-separated list of packages that contain test modules"),
('use-resources=', 'u',
"resources to use - resource names are defined by tests"),
('refcounts', 'r',
"repeat tests to search for refcount leaks (requires 'sys.gettotalrefcount')"),
]
boolean_options = ["refcounts"]
def initialize_options(self):
self.use_resources = ""
self.refcounts = False
self.tests = "comtypes.test"
def finalize_options(self):
if self.refcounts and not hasattr(sys, "gettotalrefcount"):
raise Exception("refcount option requires Python debug build")
self.tests = self.tests.split(",")
self.use_resources = self.use_resources.split(",")
def run(self):
build = self.reinitialize_command('build')
build.run()
if build.build_lib is not None:
sys.path.insert(0, build.build_lib)
# Register our ATL COM tester dll
dll = ctypes.OleDLL(r"source\debug\AvmcIfc.dll")
dll.DllRegisterServer()
import comtypes.test
comtypes.test.use_resources.extend(self.use_resources)
for name in self.tests:
package = __import__(name, globals(), locals(), ['*'])
sys.stdout.write("Testing package %s %s\n"
% (name, (sys.version, sys.platform, os.name)))
comtypes.test.run_tests(package,
"test_*.py",
self.verbose,
self.refcounts)
classifiers = [
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Operating System :: Microsoft :: Windows',
'Operating System :: Microsoft :: Windows :: Windows CE',
'Programming Language :: Python',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 3',
'Topic :: Software Development :: Libraries :: Python Modules',
]
def read_version():
# Determine the version number by reading it from the file
# 'comtypes\__init__.py'. We cannot import this file (with py3,
# at least) because it is in py2.x syntax.
ns = {}
for line in open("comtypes/__init__.py"):
if line.startswith("__version__ = "):
exec(line, ns)
break
return ns["__version__"]
if sys.version_info >= (3, 0):
# install_script does not work in Python 3 (python bug)
# Another distutils bug: it doesn't accept an empty options dict
options = {"foo": {}}
## options = {}
else:
options={"bdist_wininst": {"install_script": "clear_comtypes_cache.py"}}
setup_params = dict(
name="comtypes",
description="Pure Python COM package",
long_description = __doc__,
author="Thomas Heller",
author_email="theller@python.net",
url="http://starship.python.net/crew/theller/comtypes",
download_url="http://sourceforge.net/project/showfiles.php?group_id=115265",
license="MIT License",
package_data={
"comtypes.test": [
"TestComServer.idl",
"TestComServer.tlb",
"TestDispServer.idl",
"TestDispServer.tlb",
"mytypelib.idl",
"mylib.idl",
"mylib.tlb"
"urlhist.tlb",
"test_jscript.js",
]},
classifiers=classifiers,
scripts=["clear_comtypes_cache.py"],
options=options,
cmdclass={
'test': test,
'build_py': build_py,
},
version=read_version(),
packages=[
"comtypes",
"comtypes.client",
"comtypes.server",
"comtypes.tools",
"comtypes.test",
],
)
if __name__ == '__main__':
setup(**setup_params)