forked from illinois-dres-aitg/pyia2
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup.py
74 lines (60 loc) · 2.22 KB
/
setup.py
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
r"""A MSAA client library.
"""
import ctypes
import os
import sys
from setuptools import setup
import pyia2
from setuptools.command.develop import develop
from setuptools.command.install import install
classifiers = [
'Development Status :: 3 - Alpha',
'Intended Audience :: Developers',
'License :: OSI Approved :: LGPLv2.2',
'Operating System :: Microsoft :: Windows',
'Programming Language :: Python',
'Topic :: Software Development :: Libraries :: Python Modules',
]
def post_install():
# Display a message about registering the DLL.
print("Attempting to register IAccessible2Proxy.dll with elevated "
"privileges...")
# Do this via the Windows ShellExecuteA / ShellExecuteW functions.
# Use the ANSI function if using Python 2.
shell32 = ctypes.windll.shell32
PY2 = sys.version_info[0] == 2
ShellExecute = shell32.ShellExecuteA if PY2 else shell32.ShellExecuteW
# Get the DLL's path and attempt to register it with elevated privileges.
dll_path = os.path.join(os.getcwd(), "pyia2", "IAccessible2Proxy.dll")
return_code = ShellExecute(None, "runas", "regsvr32.exe", dll_path, None, 1)
if return_code > 32:
print("Success.")
else:
print("Failed to register the DLL. It must be registered manually.")
class PostDevelopCommand(develop):
"""Post-installation for development mode."""
def run(self):
post_install()
develop.run(self)
class PostInstallCommand(install):
"""Post-installation for installation mode."""
def run(self):
post_install()
install.run(self)
setup(name="pyia2",
description="Python MSAA+IAccessible2 client library",
long_description = __doc__,
author="Jon Gunderson",
author_email="[email protected]",
url="https://github.com/illinois-dres-aitg/pyia2/tree/master",
download_url="https://github.com/illinois-dres-aitg/pyia2/tree/master/pyia2",
license="LGPLv2.2",
classifiers=classifiers,
version=pyia2.__version__,
packages=["pyia2"],
package_data={"": ["*.tlb"]},
install_requires=["comtypes", "six"],
cmdclass={
'develop': PostDevelopCommand,
'install': PostInstallCommand,
})