forked from gvalkov/python-evdev
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
Latest commit
executable file
·131 lines (96 loc) · 3.65 KB
/
Copy pathsetup.py
File metadata and controls
executable file
·131 lines (96 loc) · 3.65 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
#!/usr/bin/env python
# encoding: utf-8
importos
importsys
importtextwrap
fromos.pathimportabspath, dirname, joinaspjoin
fromdistutils.command.buildimportbuild
fromsetuptools.command.developimportdevelop
fromsetuptools.command.bdist_eggimportbdist_egg
fromsetuptoolsimportsetup, Extension, Command
here=abspath(dirname(__file__))
requires= ()
test_requires= ('pytest',)
classifiers= (
'Development Status :: 4 - Beta',
# 'Development Status :: 5 - Production/Stable',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.2',
'Programming Language :: Python :: 3.3',
'Operating System :: POSIX :: Linux',
'Intended Audience :: Developers',
'Topic :: Software Development :: Libraries',
'License :: OSI Approved :: BSD License',
'Programming Language :: Python :: Implementation :: CPython',
)
input_c=Extension('evdev._input', sources=['evdev/input.c'], ) # extra_compile_args=['-O0'])
uinput_c=Extension('evdev._uinput', sources=['evdev/uinput.c'], ) # extra_compile_args=['-O0'])
ecodes_c=Extension('evdev._ecodes', sources=['evdev/ecodes.c'], ) # extra_compile_args=['-O0'])
kw= {
'name' : 'evdev',
'version' : '0.3.3',
'description' : 'bindings for the linux input handling subsystem',
'long_description' : open(pjoin(here, 'README.rst')).read(),
'author' : 'Georgi Valkov',
'author_email' : 'georgi.t.valkov@gmail.com',
'license' : 'New BSD License',
'keywords' : 'evdev input uinput',
'classifiers' : classifiers,
'url' : 'https://github.com/gvalkov/python-evdev',
'packages' : ['evdev'],
'ext_modules' : [input_c, uinput_c, ecodes_c],
'install_requires' : requires,
'tests_require' : test_requires,
'include_package_data' : False,
'zip_safe' : True,
'cmdclass' : {},
}
defcreate_ecodes():
# :todo: expose as a command option
header='/usr/include/linux/input.h'
ifnotos.path.isfile(header):
msg='''\
The linux/input.h header file is missing. You will have to
install the headers for your kernel in order to continue:
yum install kernel-headers-$(uname -r)
apt-get intall linux-headers-$(uname -r)
pacman -S kernel-headers\n\n'''
sys.stderr.write(textwrap.dedent(msg))
sys.exit(1)
fromsubprocessimportcheck_call
print('writing ecodes.c (using {})'.format(header))
check_call('bash ./ecodes.sh {} > ecodes.c'.format(header),
cwd='{}/evdev'.format(here),
shell=True)
# :todo: figure out a smarter way to do this
# :note: subclassing build_ext doesn't really cut it
classBuildCommand(build):
defrun(self):
create_ecodes()
build.run(self)
classDevelopCommand(develop):
defrun(self):
create_ecodes()
develop.run(self)
classBdistEggCommand(bdist_egg):
defrun(self):
create_ecodes()
bdist_egg.run(self)
classPyTest(Command):
''' setup.py test -> py.test tests '''
user_options= []
definitialize_options(self):
pass
deffinalize_options(self):
pass
defrun(self):
fromsubprocessimportcall
errno=call(('py.test', 'tests'))
raiseSystemExit(errno)
kw['cmdclass']['test'] =PyTest
kw['cmdclass']['build'] =BuildCommand
kw['cmdclass']['develop'] =DevelopCommand
kw['cmdclass']['bdist_egg'] =BdistEggCommand
if__name__=='__main__':
setup(**kw)