forked from trezor/cython-hidapi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
124 lines (116 loc) · 3.62 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
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
#!/usr/bin/python
from setuptools import setup, Extension
import os
import sys
hidapi_topdir = os.path.join('hidapi')
hidapi_include = os.path.join(hidapi_topdir, 'hidapi')
system_hidapi = 0
libs= []
src = ['hid.pyx', 'chid.pxd']
def hidapi_src(platform):
return os.path.join(hidapi_topdir, platform, 'hid.c')
if '--with-system-hidapi' in sys.argv:
sys.argv.remove('--with-system-hidapi')
system_hidapi = 1
hidapi_include = '/usr/include/hidapi'
if sys.platform.startswith('linux'):
modules = []
if '--without-libusb' in sys.argv:
sys.argv.remove('--without-libusb')
hidraw_module = 'hid'
else:
hidraw_module = 'hidraw'
libs = ['usb-1.0', 'udev', 'rt']
if system_hidapi == 1:
libs.append('hidapi-libusb')
else:
src.append(hidapi_src('libusb'))
modules.append(
Extension('hid',
sources = src,
include_dirs = [hidapi_include, '/usr/include/libusb-1.0'],
libraries = libs,
)
)
libs = ['udev', 'rt']
src = ['hidraw.pyx', 'chid.pxd']
if system_hidapi == 1:
libs.append('hidapi-hidraw')
else:
src.append(hidapi_src('linux'))
modules.append(
Extension(hidraw_module,
sources = src,
include_dirs = [hidapi_include],
libraries = libs,
)
)
if sys.platform.startswith('darwin'):
os.environ['CFLAGS'] = '-framework IOKit -framework CoreFoundation'
os.environ['LDFLAGS'] = ''
if system_hidapi == True:
libs.append('hidapi')
else:
src.append(hidapi_src('mac'))
modules = [
Extension('hid',
sources = src,
include_dirs = [hidapi_include],
libraries = libs,
)
]
if sys.platform.startswith('win') or sys.platform.startswith('cygwin'):
libs = ['setupapi']
if system_hidapi == True:
libs.append('hidapi')
else:
src.append(hidapi_src('windows'))
modules = [
Extension('hid',
sources = src,
include_dirs = [hidapi_include],
libraries = libs,
)
]
if 'bsd' in sys.platform:
libs = ['usb-1.0']
if system_hidapi == True:
libs.append('hidapi-libusb')
else:
src.append(hidapi_src('libusb'))
modules = [
Extension('hid',
sources = src,
include_dirs = [hidapi_include, '/usr/include/libusb-1.0'],
libraries = libs,
)
]
setup(
name = 'hidapi',
version = '0.9.0',
description = 'A Cython interface to the hidapi from https://github.com/libusb/hidapi',
author = 'Gary Bishop',
author_email = 'gb@cs.unc.edu',
maintainer = 'Pavol Rusnak',
maintainer_email = 'stick@gk2.sk',
url = 'https://github.com/trezor/cython-hidapi',
package_dir = {'hid': 'hidapi/*'},
classifiers = [
'Operating System :: MacOS :: MacOS X',
'Operating System :: Microsoft :: Windows',
'Operating System :: POSIX',
'License :: OSI Approved :: BSD License',
'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.2',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
],
ext_modules = modules,
setup_requires = ['Cython'],
install_requires = ['setuptools>=19.0'],
)