comtypes 1.1.14__zip → 1.2.1__zip
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {comtypes-1.1.14 → comtypes-1.2.1}/CHANGES.txt +37 -0
- comtypes-1.2.1/PKG-INFO +79 -0
- comtypes-1.2.1/README.md +59 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/__init__.py +302 -555
- comtypes-1.2.1/comtypes/_memberspec.py +520 -0
- comtypes-1.2.1/comtypes/_npsupport.py +143 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/automation.py +99 -11
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/client/__init__.py +80 -26
- comtypes-1.2.1/comtypes/client/_generate.py +274 -0
- comtypes-1.2.1/comtypes/hints.pyi +26 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/persist.py +14 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/safearray.py +22 -21
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/test/__init__.py +0 -7
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/test/test_client.py +35 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/test/test_dict.py +0 -4
- comtypes-1.2.1/comtypes/test/test_npsupport.py +343 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/test/test_safearray.py +2 -235
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/test/test_variant.py +6 -59
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/tools/codegenerator.py +454 -337
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/tools/tlbparser.py +56 -75
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/tools/typedesc.py +31 -3
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/tools/typedesc_base.py +28 -1
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/typeinfo.py +291 -121
- comtypes-1.2.1/comtypes.egg-info/PKG-INFO +79 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes.egg-info/SOURCES.txt +4 -1
- {comtypes-1.1.14 → comtypes-1.2.1}/setup.cfg +0 -1
- {comtypes-1.1.14 → comtypes-1.2.1}/setup.py +15 -8
- comtypes-1.1.14/PKG-INFO +0 -50
- comtypes-1.1.14/README.md +0 -31
- comtypes-1.1.14/comtypes/client/_generate.py +0 -257
- comtypes-1.1.14/comtypes/npsupport.py +0 -125
- comtypes-1.1.14/comtypes.egg-info/PKG-INFO +0 -50
- {comtypes-1.1.14 → comtypes-1.2.1}/LICENSE.txt +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/MANIFEST.in +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/clear_comtypes_cache.py +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/GUID.py +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/_comobject.py +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/_meta.py +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/_safearray.py +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/client/_code_cache.py +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/client/_constants.py +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/client/_events.py +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/client/dynamic.py +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/client/lazybind.py +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/connectionpoints.py +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/errorinfo.py +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/git.py +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/hresult.py +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/logutil.py +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/messageloop.py +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/patcher.py +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/server/__init__.py +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/server/automation.py +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/server/connectionpoints.py +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/server/inprocserver.py +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/server/localserver.py +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/server/register.py +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/server/w_getopt.py +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/shelllink.py +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/test/TestComServer.idl +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/test/TestComServer.py +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/test/TestComServer.tlb +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/test/TestDispServer.idl +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/test/TestDispServer.py +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/test/TestDispServer.tlb +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/test/find_memleak.py +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/test/mylib.idl +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/test/mytypelib.idl +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/test/runtests.py +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/test/setup.py +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/test/test_BSTR.py +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/test/test_DISPPARAMS.py +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/test/test_GUID.py +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/test/test_QueryService.py +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/test/test_agilent.py +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/test/test_avmc.py +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/test/test_basic.py +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/test/test_casesensitivity.py +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/test/test_collections.py +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/test/test_comserver.py +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/test/test_createwrappers.py +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/test/test_dispinterface.py +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/test/test_dyndispatch.py +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/test/test_excel.py +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/test/test_findgendir.py +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/test/test_getactiveobj.py +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/test/test_ie.py +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/test/test_jscript.js +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/test/test_msscript.py +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/test/test_outparam.py +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/test/test_propputref.py +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/test/test_pump_events.py +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/test/test_sapi.py +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/test/test_server.py +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/test/test_showevents.py +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/test/test_subinterface.py +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/test/test_typeinfo.py +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/test/test_urlhistory.py +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/test/test_win32com_interop.py +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/test/test_wmi.py +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/test/test_word.py +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/tools/__init__.py +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/util.py +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes/viewobject.py +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes.egg-info/dependency_links.txt +0 -0
- {comtypes-1.1.14 → comtypes-1.2.1}/comtypes.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: comtypes
|
|
3
|
+
Version: 1.2.1
|
|
4
|
+
Summary: Pure Python COM package
|
|
5
|
+
Home-page: https://github.com/enthought/comtypes
|
|
6
|
+
Author: Thomas Heller
|
|
7
|
+
Author-email: theller@python.net
|
|
8
|
+
License: MIT License
|
|
9
|
+
Download-URL: https://github.com/enthought/comtypes/releases
|
|
10
|
+
Description: # comtypes
|
|
11
|
+
|
|
12
|
+
[](https://pypi.org/project/comtypes/) [](https://pypi.org/project/comtypes/) [](https://pypi.org/project/comtypes/) [](https://pypi.org/project/comtypes/)
|
|
13
|
+
[](https://github.com/enthought/comtypes/stargazers) [](https://github.com/enthought/comtypes/network/members)
|
|
14
|
+
|
|
15
|
+
## About
|
|
16
|
+
|
|
17
|
+
`comtypes` is a lightweight `Python` COM package, based on the [`ctypes`](https://docs.python.org/library/ctypes.html) FFI library.
|
|
18
|
+
|
|
19
|
+
`comtypes` allows to define, call, and implement custom and dispatch-based COM interfaces in pure `Python`.
|
|
20
|
+
|
|
21
|
+
This package works on Windows only.
|
|
22
|
+
- [`comtypes==1.1.7`](https://pypi.org/project/comtypes/1.1.7/) is the last version supporting Windows CE.
|
|
23
|
+
|
|
24
|
+
Available on `Python` 2.7 and 3.3-3.11.
|
|
25
|
+
- [Supporting `Python` 2.7 will be dropped](#ongoing-plans).
|
|
26
|
+
|
|
27
|
+
## Where to get it
|
|
28
|
+
|
|
29
|
+
The source code is currently hosted on GitHub at:
|
|
30
|
+
https://github.com/enthought/comtypes
|
|
31
|
+
|
|
32
|
+
An installer for the latest released version is available at the [Python Package Index (PyPI)](https://pypi.org/project/comtypes).
|
|
33
|
+
|
|
34
|
+
```sh
|
|
35
|
+
# PyPI
|
|
36
|
+
pip install comtypes
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Dependencies
|
|
40
|
+
|
|
41
|
+
`comtypes` requires no third-party packages to run - this is truly **pure** `Python` package.
|
|
42
|
+
|
|
43
|
+
Optional features include the follows...
|
|
44
|
+
- to process arrays as `numpy`'s `ndarray`
|
|
45
|
+
- type hints be interpreted by `mypy` or several static type checkers
|
|
46
|
+
|
|
47
|
+
But these third-parties are not required as a prerequisite for runtime.
|
|
48
|
+
|
|
49
|
+
## Community of the developers
|
|
50
|
+
|
|
51
|
+
Tracking issues, reporting bugs and contributing to the codebase and documentation are on GitHub at:
|
|
52
|
+
https://github.com/enthought/comtypes
|
|
53
|
+
|
|
54
|
+
<a id="ongoing-plans"></a>
|
|
55
|
+
### Ongoing plans
|
|
56
|
+
For the time being, the development target branch of this package will be the [`drop_py2` branch](https://github.com/enthought/comtypes/tree/drop_py2) and the [`master` branch](https://github.com/enthought/comtypes/tree/master) will be in maintenance-only-mode.
|
|
57
|
+
|
|
58
|
+
As the name suggests, `drop_py2` is a mid-term-planning branch to drop supporting `Python` 2.x from this package, and start supporting `Python` 3.x only.
|
|
59
|
+
|
|
60
|
+
The `drop_py2` branch will be merged into the `master` branch in the future, and the `master` branch will back to the development target branch and be renamed to `main`.
|
|
61
|
+
Until then, no changes will be made to the `master` branch except in the case of corresponding to regressions.
|
|
62
|
+
|
|
63
|
+
Please see [the GitHub issue](https://github.com/enthought/comtypes/issues/392) for policy and progress.
|
|
64
|
+
|
|
65
|
+
## Documentation:
|
|
66
|
+
|
|
67
|
+
The documentation is currently hosted on pythonhosted at:
|
|
68
|
+
https://pythonhosted.org/comtypes
|
|
69
|
+
|
|
70
|
+
Platform: UNKNOWN
|
|
71
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
72
|
+
Classifier: Intended Audience :: Developers
|
|
73
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
74
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
75
|
+
Classifier: Programming Language :: Python
|
|
76
|
+
Classifier: Programming Language :: Python :: 2.7
|
|
77
|
+
Classifier: Programming Language :: Python :: 3
|
|
78
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
79
|
+
Description-Content-Type: text/markdown
|
|
@@ -7,16 +7,18 @@ setup.py
|
|
|
7
7
|
comtypes/GUID.py
|
|
8
8
|
comtypes/__init__.py
|
|
9
9
|
comtypes/_comobject.py
|
|
10
|
+
comtypes/_memberspec.py
|
|
10
11
|
comtypes/_meta.py
|
|
12
|
+
comtypes/_npsupport.py
|
|
11
13
|
comtypes/_safearray.py
|
|
12
14
|
comtypes/automation.py
|
|
13
15
|
comtypes/connectionpoints.py
|
|
14
16
|
comtypes/errorinfo.py
|
|
15
17
|
comtypes/git.py
|
|
18
|
+
comtypes/hints.pyi
|
|
16
19
|
comtypes/hresult.py
|
|
17
20
|
comtypes/logutil.py
|
|
18
21
|
comtypes/messageloop.py
|
|
19
|
-
comtypes/npsupport.py
|
|
20
22
|
comtypes/patcher.py
|
|
21
23
|
comtypes/persist.py
|
|
22
24
|
comtypes/safearray.py
|
|
@@ -75,6 +77,7 @@ comtypes/test/test_getactiveobj.py
|
|
|
75
77
|
comtypes/test/test_ie.py
|
|
76
78
|
comtypes/test/test_jscript.js
|
|
77
79
|
comtypes/test/test_msscript.py
|
|
80
|
+
comtypes/test/test_npsupport.py
|
|
78
81
|
comtypes/test/test_outparam.py
|
|
79
82
|
comtypes/test/test_propputref.py
|
|
80
83
|
comtypes/test/test_pump_events.py
|
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
"""comtypes package install script"""
|
|
2
2
|
import sys
|
|
3
3
|
import os
|
|
4
|
-
import ctypes
|
|
5
4
|
import subprocess
|
|
6
5
|
|
|
7
|
-
from
|
|
8
|
-
from
|
|
9
|
-
from setuptools import
|
|
6
|
+
from setuptools import Command, setup
|
|
7
|
+
from setuptools.command.install import install
|
|
8
|
+
from setuptools.command.build_py import build_py
|
|
10
9
|
|
|
11
|
-
from distutils.command.build_py import build_py
|
|
12
10
|
|
|
13
11
|
with open('README.md') as readme_stream:
|
|
14
12
|
readme = readme_stream.read()
|
|
15
13
|
|
|
14
|
+
|
|
16
15
|
class test(Command):
|
|
17
16
|
# Original version of this class posted
|
|
18
17
|
# by Berthold Hoellmann to distutils-sig@python.org
|
|
@@ -24,7 +23,8 @@ class test(Command):
|
|
|
24
23
|
('use-resources=', 'u',
|
|
25
24
|
"resources to use - resource names are defined by tests"),
|
|
26
25
|
('refcounts', 'r',
|
|
27
|
-
"repeat tests to search for refcount leaks (requires
|
|
26
|
+
"repeat tests to search for refcount leaks (requires "
|
|
27
|
+
"'sys.gettotalrefcount')"),
|
|
28
28
|
]
|
|
29
29
|
|
|
30
30
|
boolean_options = ["refcounts"]
|
|
@@ -64,6 +64,7 @@ class test(Command):
|
|
|
64
64
|
self.refcounts)
|
|
65
65
|
self.failure = self.failure or package_failure
|
|
66
66
|
|
|
67
|
+
|
|
67
68
|
classifiers = [
|
|
68
69
|
'Development Status :: 5 - Production/Stable',
|
|
69
70
|
'Intended Audience :: Developers',
|
|
@@ -75,6 +76,7 @@ classifiers = [
|
|
|
75
76
|
'Topic :: Software Development :: Libraries :: Python Modules',
|
|
76
77
|
]
|
|
77
78
|
|
|
79
|
+
|
|
78
80
|
def read_version():
|
|
79
81
|
# Determine the version number by reading it from the file
|
|
80
82
|
# 'comtypes\__init__.py'. We cannot import this file (with py3,
|
|
@@ -108,7 +110,8 @@ class post_install(install):
|
|
|
108
110
|
install.run(self)
|
|
109
111
|
# Custom script we run at the end of installing
|
|
110
112
|
if not self.dry_run and not self.root:
|
|
111
|
-
filename = os.path.join(
|
|
113
|
+
filename = os.path.join(
|
|
114
|
+
self.install_scripts, "clear_comtypes_cache.py")
|
|
112
115
|
if not os.path.isfile(filename):
|
|
113
116
|
raise RuntimeError("Can't find '%s'" % (filename,))
|
|
114
117
|
print("Executing post install script...")
|
|
@@ -122,7 +125,8 @@ class post_install(install):
|
|
|
122
125
|
setup_params = dict(
|
|
123
126
|
name="comtypes",
|
|
124
127
|
description="Pure Python COM package",
|
|
125
|
-
long_description
|
|
128
|
+
long_description=readme,
|
|
129
|
+
long_description_content_type="text/markdown",
|
|
126
130
|
author="Thomas Heller",
|
|
127
131
|
author_email="theller@python.net",
|
|
128
132
|
url="https://github.com/enthought/comtypes",
|
|
@@ -139,6 +143,9 @@ setup_params = dict(
|
|
|
139
143
|
"mylib.tlb"
|
|
140
144
|
"urlhist.tlb",
|
|
141
145
|
"test_jscript.js",
|
|
146
|
+
],
|
|
147
|
+
"comtypes": [
|
|
148
|
+
"hints.pyi"
|
|
142
149
|
]},
|
|
143
150
|
classifiers=classifiers,
|
|
144
151
|
|
comtypes-1.1.14/PKG-INFO
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 1.1
|
|
2
|
-
Name: comtypes
|
|
3
|
-
Version: 1.1.14
|
|
4
|
-
Summary: Pure Python COM package
|
|
5
|
-
Home-page: https://github.com/enthought/comtypes
|
|
6
|
-
Author: Thomas Heller
|
|
7
|
-
Author-email: theller@python.net
|
|
8
|
-
License: MIT License
|
|
9
|
-
Download-URL: https://github.com/enthought/comtypes/releases
|
|
10
|
-
Description: comtypes
|
|
11
|
-
========
|
|
12
|
-
|
|
13
|
-
**comtypes** is a lightweight Python COM package, based on the ctypes_
|
|
14
|
-
FFI library, in less than 10000 lines of code (not counting the
|
|
15
|
-
tests).
|
|
16
|
-
|
|
17
|
-
**comtypes** allows to define, call, and implement custom and
|
|
18
|
-
dispatch-based COM interfaces in pure Python. It works on Windows and
|
|
19
|
-
64-bit Windows. Windows CE support was dropped since comtypes==1.1.8.
|
|
20
|
-
|
|
21
|
-
Documentation:
|
|
22
|
-
|
|
23
|
-
https://pythonhosted.org/comtypes
|
|
24
|
-
|
|
25
|
-
Contribute using the `source repository and issue tracker
|
|
26
|
-
<https://github.com/enthought/comtypes/>`_ on GitHub.
|
|
27
|
-
|
|
28
|
-
Mailing list:
|
|
29
|
-
|
|
30
|
-
http://gmane.org/info.php?group=gmane.comp.python.comtypes.user
|
|
31
|
-
|
|
32
|
-
https://lists.sourceforge.net/lists/listinfo/comtypes-users/
|
|
33
|
-
|
|
34
|
-
Download:
|
|
35
|
-
|
|
36
|
-
Releases can be downloaded in the PyPI page:
|
|
37
|
-
|
|
38
|
-
https://pypi.python.org/pypi/comtypes
|
|
39
|
-
|
|
40
|
-
.. _ctypes: http://docs.python.org/lib/module-ctypes.html
|
|
41
|
-
|
|
42
|
-
Platform: UNKNOWN
|
|
43
|
-
Classifier: Development Status :: 5 - Production/Stable
|
|
44
|
-
Classifier: Intended Audience :: Developers
|
|
45
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
46
|
-
Classifier: Operating System :: Microsoft :: Windows
|
|
47
|
-
Classifier: Programming Language :: Python
|
|
48
|
-
Classifier: Programming Language :: Python :: 2.7
|
|
49
|
-
Classifier: Programming Language :: Python :: 3
|
|
50
|
-
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
comtypes-1.1.14/README.md
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
comtypes
|
|
2
|
-
========
|
|
3
|
-
|
|
4
|
-
**comtypes** is a lightweight Python COM package, based on the ctypes_
|
|
5
|
-
FFI library, in less than 10000 lines of code (not counting the
|
|
6
|
-
tests).
|
|
7
|
-
|
|
8
|
-
**comtypes** allows to define, call, and implement custom and
|
|
9
|
-
dispatch-based COM interfaces in pure Python. It works on Windows and
|
|
10
|
-
64-bit Windows. Windows CE support was dropped since comtypes==1.1.8.
|
|
11
|
-
|
|
12
|
-
Documentation:
|
|
13
|
-
|
|
14
|
-
https://pythonhosted.org/comtypes
|
|
15
|
-
|
|
16
|
-
Contribute using the `source repository and issue tracker
|
|
17
|
-
<https://github.com/enthought/comtypes/>`_ on GitHub.
|
|
18
|
-
|
|
19
|
-
Mailing list:
|
|
20
|
-
|
|
21
|
-
http://gmane.org/info.php?group=gmane.comp.python.comtypes.user
|
|
22
|
-
|
|
23
|
-
https://lists.sourceforge.net/lists/listinfo/comtypes-users/
|
|
24
|
-
|
|
25
|
-
Download:
|
|
26
|
-
|
|
27
|
-
Releases can be downloaded in the PyPI page:
|
|
28
|
-
|
|
29
|
-
https://pypi.python.org/pypi/comtypes
|
|
30
|
-
|
|
31
|
-
.. _ctypes: http://docs.python.org/lib/module-ctypes.html
|
|
@@ -1,257 +0,0 @@
|
|
|
1
|
-
from __future__ import print_function
|
|
2
|
-
import types
|
|
3
|
-
import os
|
|
4
|
-
import sys
|
|
5
|
-
|
|
6
|
-
import comtypes
|
|
7
|
-
from comtypes import GUID
|
|
8
|
-
import comtypes.client
|
|
9
|
-
import comtypes.tools.codegenerator
|
|
10
|
-
import comtypes.tools.tlbparser
|
|
11
|
-
from comtypes.typeinfo import LoadRegTypeLib, LoadTypeLibEx
|
|
12
|
-
import importlib
|
|
13
|
-
|
|
14
|
-
import logging
|
|
15
|
-
logger = logging.getLogger(__name__)
|
|
16
|
-
|
|
17
|
-
if sys.version_info >= (3, 0):
|
|
18
|
-
base_text_type = str
|
|
19
|
-
import winreg
|
|
20
|
-
import io
|
|
21
|
-
else:
|
|
22
|
-
base_text_type = basestring
|
|
23
|
-
import _winreg as winreg
|
|
24
|
-
import cStringIO as io
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
PATH = os.environ["PATH"].split(os.pathsep)
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
def _my_import(fullname):
|
|
31
|
-
"""helper function to import dotted modules"""
|
|
32
|
-
import comtypes.gen
|
|
33
|
-
if comtypes.client.gen_dir \
|
|
34
|
-
and comtypes.client.gen_dir not in comtypes.gen.__path__:
|
|
35
|
-
comtypes.gen.__path__.append(comtypes.client.gen_dir)
|
|
36
|
-
return importlib.import_module(fullname)
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
def _name_module(tlib):
|
|
40
|
-
"""Determine the name of a typelib wrapper module"""
|
|
41
|
-
libattr = tlib.GetLibAttr()
|
|
42
|
-
modname = "_%s_%s_%s_%s" % \
|
|
43
|
-
(str(libattr.guid)[1:-1].replace("-", "_"),
|
|
44
|
-
libattr.lcid,
|
|
45
|
-
libattr.wMajorVerNum,
|
|
46
|
-
libattr.wMinorVerNum)
|
|
47
|
-
return "comtypes.gen." + modname
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
def _resolve_filename(tlib_string, dirpath):
|
|
51
|
-
"""Tries to make sense of a type library specified as a string.
|
|
52
|
-
|
|
53
|
-
Args:
|
|
54
|
-
tlib_string: type library designator
|
|
55
|
-
dirpath: a directory to relativize the location
|
|
56
|
-
|
|
57
|
-
Returns:
|
|
58
|
-
(abspath, True) or (relpath, False):
|
|
59
|
-
where relpath is an unresolved path.
|
|
60
|
-
"""
|
|
61
|
-
assert isinstance(tlib_string, base_text_type)
|
|
62
|
-
# pathname of type library
|
|
63
|
-
if os.path.isabs(tlib_string):
|
|
64
|
-
# a specific location
|
|
65
|
-
return tlib_string, True
|
|
66
|
-
elif dirpath:
|
|
67
|
-
abspath = os.path.normpath(os.path.join(dirpath, tlib_string))
|
|
68
|
-
if os.path.exists(abspath):
|
|
69
|
-
return abspath, True
|
|
70
|
-
# try with respect to cwd (if _getmodule executed from command line)
|
|
71
|
-
abspath = os.path.abspath(tlib_string)
|
|
72
|
-
if os.path.exists(abspath):
|
|
73
|
-
return abspath, True
|
|
74
|
-
# Otherwise it may still be that the file is on Windows search
|
|
75
|
-
# path for typelibs, and we leave the pathname alone.
|
|
76
|
-
return tlib_string, False
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
def GetModule(tlib):
|
|
80
|
-
"""Create a module wrapping a COM typelibrary on demand.
|
|
81
|
-
|
|
82
|
-
'tlib' must be an ITypeLib COM pointer instance, the pathname of a
|
|
83
|
-
type library, a COM CLSID GUID, or a tuple/list specifying the
|
|
84
|
-
arguments to a comtypes.typeinfo.LoadRegTypeLib call:
|
|
85
|
-
|
|
86
|
-
(libid, wMajorVerNum, wMinorVerNum, lcid=0)
|
|
87
|
-
|
|
88
|
-
Or it can be an object with _reg_libid_ and _reg_version_
|
|
89
|
-
attributes.
|
|
90
|
-
|
|
91
|
-
A relative pathname is interpreted as relative to the callers
|
|
92
|
-
__file__, if this exists.
|
|
93
|
-
|
|
94
|
-
This function determines the module name from the typelib
|
|
95
|
-
attributes, then tries to import it. If that fails because the
|
|
96
|
-
module doesn't exist, the module is generated into the
|
|
97
|
-
comtypes.gen package.
|
|
98
|
-
|
|
99
|
-
It is possible to delete the whole `comtypes/gen` directory to
|
|
100
|
-
remove all generated modules, the directory and the __init__.py
|
|
101
|
-
file in it will be recreated when needed.
|
|
102
|
-
|
|
103
|
-
If comtypes.gen __path__ is not a directory (in a frozen
|
|
104
|
-
executable it lives in a zip archive), generated modules are only
|
|
105
|
-
created in memory without writing them to the file system.
|
|
106
|
-
|
|
107
|
-
Example:
|
|
108
|
-
|
|
109
|
-
GetModule("shdocvw.dll")
|
|
110
|
-
|
|
111
|
-
would create modules named
|
|
112
|
-
|
|
113
|
-
comtypes.gen._EAB22AC0_30C1_11CF_A7EB_0000C05BAE0B_0_1_1
|
|
114
|
-
comtypes.gen.SHDocVw
|
|
115
|
-
|
|
116
|
-
containing the Python wrapper code for the type library used by
|
|
117
|
-
Internet Explorer. The former module contains all the code, the
|
|
118
|
-
latter is a short stub loading the former.
|
|
119
|
-
"""
|
|
120
|
-
if isinstance(tlib, base_text_type):
|
|
121
|
-
tlib_string = tlib
|
|
122
|
-
# if a relative pathname is used, we try to interpret it relative to the
|
|
123
|
-
# directory of the calling module (if not from command line)
|
|
124
|
-
frame = sys._getframe(1)
|
|
125
|
-
_file_ = frame.f_globals.get("__file__", None)
|
|
126
|
-
pathname, is_abs = _resolve_filename(tlib_string, _file_ and os.path.dirname(_file_))
|
|
127
|
-
logger.debug("GetModule(%s), resolved: %s", pathname, is_abs)
|
|
128
|
-
tlib = _load_tlib(pathname) # don't register
|
|
129
|
-
if not is_abs:
|
|
130
|
-
# try to get path after loading, but this only works if already registered
|
|
131
|
-
pathname = comtypes.tools.tlbparser.get_tlib_filename(tlib)
|
|
132
|
-
if pathname is None:
|
|
133
|
-
logger.info("GetModule(%s): could not resolve to a filename", tlib)
|
|
134
|
-
pathname = tlib_string
|
|
135
|
-
# if above path torture resulted in an absolute path, then the file exists (at this point)!
|
|
136
|
-
assert not(os.path.isabs(pathname)) or os.path.exists(pathname)
|
|
137
|
-
else:
|
|
138
|
-
pathname = None
|
|
139
|
-
tlib = _load_tlib(tlib)
|
|
140
|
-
logger.debug("GetModule(%s)", tlib.GetLibAttr())
|
|
141
|
-
# create and import the real typelib wrapper module
|
|
142
|
-
mod = _create_wrapper_module(tlib, pathname)
|
|
143
|
-
# try to get the friendly-name, if not, returns the real typelib wrapper module
|
|
144
|
-
try:
|
|
145
|
-
modulename = tlib.GetDocumentation(-1)[0]
|
|
146
|
-
except comtypes.COMError:
|
|
147
|
-
return mod
|
|
148
|
-
if modulename is None:
|
|
149
|
-
return mod
|
|
150
|
-
if sys.version_info < (3, 0):
|
|
151
|
-
modulename = modulename.encode("mbcs")
|
|
152
|
-
# create and import the friendly-named module
|
|
153
|
-
return _create_friendly_module(tlib, modulename)
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
def _load_tlib(obj):
|
|
157
|
-
"""Load a pointer of ITypeLib on demand."""
|
|
158
|
-
# obj is a filepath or a ProgID
|
|
159
|
-
if isinstance(obj, base_text_type):
|
|
160
|
-
# in any case, attempt to load and if tlib_string is not valid, then raise
|
|
161
|
-
# as "OSError: [WinError -2147312566] Error loading type library/DLL"
|
|
162
|
-
return LoadTypeLibEx(obj)
|
|
163
|
-
# obj is a tlib GUID contain a clsid
|
|
164
|
-
elif isinstance(obj, GUID):
|
|
165
|
-
clsid = str(obj)
|
|
166
|
-
# lookup associated typelib in registry
|
|
167
|
-
with winreg.OpenKey(winreg.HKEY_CLASSES_ROOT, r"CLSID\%s\TypeLib" % clsid) as key:
|
|
168
|
-
libid = winreg.EnumValue(key, 0)[1]
|
|
169
|
-
with winreg.OpenKey(winreg.HKEY_CLASSES_ROOT, r"CLSID\%s\Version" % clsid) as key:
|
|
170
|
-
version = winreg.EnumValue(key, 0)[1].split(".")
|
|
171
|
-
return LoadRegTypeLib(GUID(libid), int(version[0]), int(version[1]), 0)
|
|
172
|
-
# obj is a sequence containing libid
|
|
173
|
-
elif isinstance(obj, (tuple, list)):
|
|
174
|
-
libid, version = obj[0], obj[1:]
|
|
175
|
-
if not version: # case of version numbers are not containing
|
|
176
|
-
with winreg.OpenKey(winreg.HKEY_CLASSES_ROOT, r"TypeLib\%s" % libid) as key:
|
|
177
|
-
version = [int(v, base=16) for v in winreg.EnumKey(key, 0).split(".")]
|
|
178
|
-
return LoadRegTypeLib(GUID(libid), *version)
|
|
179
|
-
# obj is a COMObject implementation
|
|
180
|
-
elif hasattr(obj, "_reg_libid_"):
|
|
181
|
-
return LoadRegTypeLib(GUID(obj._reg_libid_), *obj._reg_version_)
|
|
182
|
-
# perhaps obj is a pointer of ITypeLib
|
|
183
|
-
return obj
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
def _invalidate_import_caches():
|
|
187
|
-
"""clear the import cache to make sure Python sees newly created modules"""
|
|
188
|
-
if hasattr(importlib, "invalidate_caches"):
|
|
189
|
-
importlib.invalidate_caches()
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
def _create_friendly_module(tlib, modulename):
|
|
193
|
-
"""helper which creates and imports the friendly-named module."""
|
|
194
|
-
try:
|
|
195
|
-
mod = _my_import("comtypes.gen." + modulename)
|
|
196
|
-
except Exception as details:
|
|
197
|
-
logger.info("Could not import comtypes.gen.%s: %s", modulename, details)
|
|
198
|
-
else:
|
|
199
|
-
return mod
|
|
200
|
-
# the module is always regenerated if the import fails
|
|
201
|
-
logger.info("# Generating comtypes.gen.%s", modulename)
|
|
202
|
-
# determine the Python module name
|
|
203
|
-
fullname = _name_module(tlib)
|
|
204
|
-
modname = fullname.split(".")[-1]
|
|
205
|
-
code = "from comtypes.gen import %s\nglobals().update(%s.__dict__)\n" % (modname, modname)
|
|
206
|
-
code += "__name__ = 'comtypes.gen.%s'" % modulename
|
|
207
|
-
if comtypes.client.gen_dir is None:
|
|
208
|
-
mod = types.ModuleType("comtypes.gen." + modulename)
|
|
209
|
-
mod.__file__ = os.path.join(os.path.abspath(comtypes.gen.__path__[0]),
|
|
210
|
-
"<memory>")
|
|
211
|
-
exec(code, mod.__dict__)
|
|
212
|
-
sys.modules["comtypes.gen." + modulename] = mod
|
|
213
|
-
setattr(comtypes.gen, modulename, mod)
|
|
214
|
-
return mod
|
|
215
|
-
# create in file system, and import it
|
|
216
|
-
with open(os.path.join(comtypes.client.gen_dir, modulename + ".py"), "w") as ofi:
|
|
217
|
-
print(code, file=ofi)
|
|
218
|
-
_invalidate_import_caches()
|
|
219
|
-
return _my_import("comtypes.gen." + modulename)
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
def _create_wrapper_module(tlib, pathname):
|
|
223
|
-
"""helper which creates and imports the real typelib wrapper module."""
|
|
224
|
-
fullname = _name_module(tlib)
|
|
225
|
-
if fullname in sys.modules:
|
|
226
|
-
return sys.modules[fullname]
|
|
227
|
-
|
|
228
|
-
modname = fullname.split(".")[-1]
|
|
229
|
-
|
|
230
|
-
try:
|
|
231
|
-
return _my_import(fullname)
|
|
232
|
-
except Exception as details:
|
|
233
|
-
logger.info("Could not import %s: %s", fullname, details)
|
|
234
|
-
|
|
235
|
-
# generate the module since it doesn't exist or is out of date
|
|
236
|
-
stream = io.StringIO()
|
|
237
|
-
logger.info("# Generating comtypes.gen.%s", modname)
|
|
238
|
-
comtypes.tools.tlbparser.generate_module(tlib, stream, pathname)
|
|
239
|
-
if comtypes.client.gen_dir is None:
|
|
240
|
-
mod = types.ModuleType(fullname)
|
|
241
|
-
mod.__file__ = os.path.join(os.path.abspath(comtypes.gen.__path__[0]),
|
|
242
|
-
"<memory>")
|
|
243
|
-
exec(stream.getvalue(), mod.__dict__)
|
|
244
|
-
sys.modules[fullname] = mod
|
|
245
|
-
setattr(comtypes.gen, modname, mod)
|
|
246
|
-
else:
|
|
247
|
-
with open(os.path.join(comtypes.client.gen_dir, modname + ".py"), "w") as ofi:
|
|
248
|
-
print(stream.getvalue(), file=ofi)
|
|
249
|
-
_invalidate_import_caches()
|
|
250
|
-
mod = _my_import(fullname)
|
|
251
|
-
return mod
|
|
252
|
-
|
|
253
|
-
################################################################
|
|
254
|
-
|
|
255
|
-
if __name__ == "__main__":
|
|
256
|
-
# When started as script, generate typelib wrapper from .tlb file.
|
|
257
|
-
GetModule(sys.argv[1])
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
""" Consolidation of numpy support utilities. """
|
|
2
|
-
import sys
|
|
3
|
-
|
|
4
|
-
try:
|
|
5
|
-
import numpy
|
|
6
|
-
except ImportError:
|
|
7
|
-
numpy = None
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
HAVE_NUMPY = numpy is not None
|
|
11
|
-
|
|
12
|
-
is_64bits = sys.maxsize > 2**32
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
def _make_variant_dtype():
|
|
16
|
-
""" Create a dtype for VARIANT. This requires support for Unions, which is
|
|
17
|
-
available in numpy version 1.7 or greater.
|
|
18
|
-
|
|
19
|
-
This does not support the decimal type.
|
|
20
|
-
|
|
21
|
-
Returns None if the dtype cannot be created.
|
|
22
|
-
|
|
23
|
-
"""
|
|
24
|
-
|
|
25
|
-
# pointer typecode
|
|
26
|
-
ptr_typecode = '<u8' if is_64bits else '<u4'
|
|
27
|
-
|
|
28
|
-
_tagBRECORD_format = [
|
|
29
|
-
('pvRecord', ptr_typecode),
|
|
30
|
-
('pRecInfo', ptr_typecode),
|
|
31
|
-
]
|
|
32
|
-
|
|
33
|
-
# overlapping typecodes only allowed in numpy version 1.7 or greater
|
|
34
|
-
U_VARIANT_format = dict(
|
|
35
|
-
names=[
|
|
36
|
-
'VT_BOOL', 'VT_I1', 'VT_I2', 'VT_I4', 'VT_I8', 'VT_INT', 'VT_UI1',
|
|
37
|
-
'VT_UI2', 'VT_UI4', 'VT_UI8', 'VT_UINT', 'VT_R4', 'VT_R8', 'VT_CY',
|
|
38
|
-
'c_wchar_p', 'c_void_p', 'pparray', 'bstrVal', '_tagBRECORD',
|
|
39
|
-
],
|
|
40
|
-
formats=[
|
|
41
|
-
'<i2', '<i1', '<i2', '<i4', '<i8', '<i4', '<u1', '<u2', '<u4',
|
|
42
|
-
'<u8', '<u4', '<f4', '<f8', '<i8', ptr_typecode, ptr_typecode,
|
|
43
|
-
ptr_typecode, ptr_typecode, _tagBRECORD_format,
|
|
44
|
-
],
|
|
45
|
-
offsets=[0] * 19 # This is what makes it a union
|
|
46
|
-
)
|
|
47
|
-
|
|
48
|
-
tagVARIANT_format = [
|
|
49
|
-
("vt", '<u2'),
|
|
50
|
-
("wReserved1", '<u2'),
|
|
51
|
-
("wReserved2", '<u2'),
|
|
52
|
-
("wReserved3", '<u2'),
|
|
53
|
-
("_", U_VARIANT_format),
|
|
54
|
-
]
|
|
55
|
-
|
|
56
|
-
return numpy.dtype(tagVARIANT_format)
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
def isndarray(value):
|
|
60
|
-
""" Check if a value is an ndarray.
|
|
61
|
-
|
|
62
|
-
This cannot succeed if numpy is not available.
|
|
63
|
-
|
|
64
|
-
"""
|
|
65
|
-
if not HAVE_NUMPY:
|
|
66
|
-
return False
|
|
67
|
-
return isinstance(value, numpy.ndarray)
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
def isdatetime64(value):
|
|
71
|
-
""" Check if a value is a datetime64.
|
|
72
|
-
|
|
73
|
-
This cannot succeed if datetime64 is not available.
|
|
74
|
-
|
|
75
|
-
"""
|
|
76
|
-
if not HAVE_NUMPY:
|
|
77
|
-
return False
|
|
78
|
-
return isinstance(value, datetime64)
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
def _check_ctypeslib_typecodes():
|
|
82
|
-
import numpy as np
|
|
83
|
-
from numpy import ctypeslib
|
|
84
|
-
try:
|
|
85
|
-
from numpy.ctypeslib import _typecodes
|
|
86
|
-
except ImportError:
|
|
87
|
-
from numpy.ctypeslib import as_ctypes_type
|
|
88
|
-
|
|
89
|
-
dtypes_to_ctypes = {}
|
|
90
|
-
|
|
91
|
-
for tp in set(np.sctypeDict.values()):
|
|
92
|
-
try:
|
|
93
|
-
ctype_for = as_ctypes_type(tp)
|
|
94
|
-
dtypes_to_ctypes[np.dtype(tp).str] = ctype_for
|
|
95
|
-
except NotImplementedError:
|
|
96
|
-
continue
|
|
97
|
-
ctypeslib._typecodes = dtypes_to_ctypes
|
|
98
|
-
return ctypeslib._typecodes
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
com_null_date64 = None
|
|
102
|
-
datetime64 = None
|
|
103
|
-
VARIANT_dtype = None
|
|
104
|
-
typecodes = {}
|
|
105
|
-
|
|
106
|
-
if HAVE_NUMPY:
|
|
107
|
-
typecodes = _check_ctypeslib_typecodes()
|
|
108
|
-
# dtype for VARIANT. This allows for packing of variants into an array, and
|
|
109
|
-
# subsequent conversion to a multi-dimensional safearray.
|
|
110
|
-
try:
|
|
111
|
-
VARIANT_dtype = _make_variant_dtype()
|
|
112
|
-
except ValueError:
|
|
113
|
-
pass
|
|
114
|
-
|
|
115
|
-
# This simplifies dependent modules
|
|
116
|
-
try:
|
|
117
|
-
from numpy import datetime64
|
|
118
|
-
except ImportError:
|
|
119
|
-
pass
|
|
120
|
-
else:
|
|
121
|
-
try:
|
|
122
|
-
# This does not work on numpy 1.6
|
|
123
|
-
com_null_date64 = datetime64("1899-12-30T00:00:00", "ns")
|
|
124
|
-
except TypeError:
|
|
125
|
-
pass
|