forked from bambocher/pocketsphinx-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
254 lines (223 loc) · 7.69 KB
/
setup.py
File metadata and controls
254 lines (223 loc) · 7.69 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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
#!/usr/bin/env python
import os
import sys
from shutil import copy, copytree, ignore_patterns
from glob import glob
from distutils.command.build import build as _build
try:
from setuptools import setup, Extension
from setuptools.command.install import install as _install
from setuptools.command.bdist_egg import bdist_egg as _bdist_egg
except ImportError:
from distutils.core import setup
from distutils.extension import Extension
from distutils.command.install import install as _install
from distutils.command.bdist_egg import bdist_egg as _bdist_egg
if sys.platform.startswith('win'):
from distutils.command.bdist_msi import bdist_msi as _bdist_msi
from distutils.command.bdist_wininst import bdist_wininst as _bdist_wininst
extra_compile_args = []
extra_link_args = []
extra_objects = []
libraries = []
libsphinxbase = (
glob('deps/sphinxbase/src/libsphinxbase/lm/*.c') +
glob('deps/sphinxbase/src/libsphinxbase/feat/*.c') +
glob('deps/sphinxbase/src/libsphinxbase/util/*.c') +
glob('deps/sphinxbase/src/libsphinxbase/fe/*.c')
)
libpocketsphinx = glob('deps/pocketsphinx/src/libpocketsphinx/*.c')
ad_sources = ['swig/sphinxbase/ad.i']
sb_sources = (
libsphinxbase +
['deps/sphinxbase/swig/sphinxbase.i']
)
ps_sources = (
libsphinxbase +
libpocketsphinx +
['deps/pocketsphinx/swig/pocketsphinx.i']
)
sb_include_dirs = [
'deps/sphinxbase/include',
'deps/sphinxbase/include/sphinxbase'
]
ps_include_dirs = ['deps/pocketsphinx/include']
define_macros = [
('SPHINXBASE_EXPORTS', None),
('POCKETSPHINX_EXPORTS', None),
('SPHINX_DLL', None),
('HAVE_CONFIG_H', None)
]
if sys.platform.startswith('win'):
ad_sources.append('deps/sphinxbase/src/libsphinxad/ad_win32.c')
sb_include_dirs.append('deps/sphinxbase/include/win32')
libraries.append('winmm')
extra_compile_args.extend([
'/wd4244',
'/wd4267',
'/wd4197',
'/wd4090',
'/wd4018',
'/wd4311',
'/wd4312',
'/wd4334',
'/wd4477',
'/wd4996'
])
extra_link_args.append('/ignore:4197')
elif sys.platform.startswith('darwin'):
ad_sources.append('deps/sphinxbase/src/libsphinxad/ad_openal.c')
sb_include_dirs.extend([
'/System/Library/Frameworks/OpenAL.framework/Versions/A/Headers',
'deps/sphinxbase/include/android'
])
extra_objects.extend([
'/System/Library/Frameworks/OpenAL.framework/Versions/A/OpenAL'
])
extra_compile_args.extend([
'-Wno-macro-redefined',
'-Wno-sign-compare',
'-Wno-logical-op-parentheses'
])
elif sys.platform.startswith('linux'):
ad_sources.append('deps/sphinxbase/src/libsphinxad/ad_pulse.c')
sb_include_dirs.append('deps/sphinxbase/include/android')
libraries.extend(['pulse', 'pulse-simple'])
extra_compile_args.extend([
'-Wno-unused-label',
'-Wno-strict-prototypes',
'-Wno-parentheses',
'-Wno-unused-but-set-variable',
'-Wno-unused-variable',
'-Wno-unused-result',
'-Wno-sign-compare',
'-Wno-misleading-indentation'
])
sb_swig_opts = (
['-modern'] +
['-I' + h for h in sb_include_dirs] +
['-Ideps/sphinxbase/swig'] +
['-outdir', 'sphinxbase']
)
ps_swig_opts = (
['-modern'] +
['-I' + h for h in sb_include_dirs + ps_include_dirs] +
['-Ideps/sphinxbase/swig'] +
['-outdir', 'pocketsphinx']
)
if not os.path.exists(os.path.join(os.path.dirname(__file__), 'pocketsphinx/model')):
copytree(os.path.join(os.path.dirname(__file__), 'deps/pocketsphinx/model/en-us'),
os.path.join(os.path.dirname(__file__), 'pocketsphinx/model'),
ignore=ignore_patterns('en-us-phone.lm.bin'))
if not os.path.exists(os.path.join(os.path.dirname(__file__), 'pocketsphinx/data')):
os.makedirs(os.path.join(os.path.dirname(__file__), 'pocketsphinx/data'))
copy(os.path.join(os.path.dirname(__file__), 'deps/pocketsphinx/test/data/goforward.raw'),
os.path.join(os.path.dirname(__file__), 'pocketsphinx/data/goforward.raw'))
class build(_build):
def run(self):
self.run_command('build_ext')
return _build.run(self)
class install(_install):
def run(self):
self.run_command('build_ext')
return _install.run(self)
class bdist_egg(_bdist_egg):
def run(self):
self.run_command('build_ext')
return _bdist_egg.run(self)
cmdclass = {
'build': build,
'install': install,
'bdist_egg': bdist_egg
}
try:
from wheel.bdist_wheel import bdist_wheel as _bdist_wheel
except ImportError:
pass
else:
class bdist_wheel(_bdist_wheel):
def run(self):
self.run_command('build_ext')
return _bdist_wheel.run(self)
cmdclass['bdist_wheel'] = bdist_wheel
if sys.platform.startswith('win'):
class bdist_msi(_bdist_msi):
def run(self):
self.run_command('build_ext')
return _bdist_msi.run(self)
class bdist_wininst(_bdist_wininst):
def run(self):
self.run_command('build_ext')
return _bdist_wininst.run(self)
cmdclass['bdist_msi'] = bdist_msi
cmdclass['bdist_wininst'] = bdist_wininst
setup(
name='pocketsphinx',
version='0.1.3',
description='Python interface to CMU Sphinxbase and Pocketsphinx libraries',
long_description=open('README.rst').read(),
author='Dmitry Prazdnichnov',
maintainer='Dmitry Prazdnichnov',
url='https://github.com/bambocher/pocketsphinx-python',
download_url='https://pypi.python.org/pypi/pocketsphinx',
packages=['sphinxbase', 'pocketsphinx'],
ext_modules=[
Extension(
name='sphinxbase._ad',
sources=ad_sources,
swig_opts=sb_swig_opts,
include_dirs=sb_include_dirs,
extra_objects=extra_objects,
libraries=libraries,
define_macros=define_macros,
extra_compile_args=extra_compile_args,
extra_link_args=extra_link_args,
),
Extension(
name='sphinxbase._sphinxbase',
sources=sb_sources,
swig_opts=sb_swig_opts,
include_dirs=sb_include_dirs,
extra_objects=extra_objects,
define_macros=define_macros,
extra_compile_args=extra_compile_args,
extra_link_args=extra_link_args,
),
Extension(
name='pocketsphinx._pocketsphinx',
sources=ps_sources,
swig_opts=ps_swig_opts,
include_dirs=sb_include_dirs + ps_include_dirs,
extra_objects=extra_objects,
define_macros=define_macros,
extra_compile_args=extra_compile_args,
extra_link_args=extra_link_args
)
],
cmdclass=cmdclass,
classifiers=[
'Development Status :: 2 - Pre-Alpha',
'Operating System :: Microsoft :: Windows',
'Operating System :: POSIX :: Linux',
'Operating System :: MacOS',
'License :: OSI Approved :: BSD License',
'Programming Language :: Python :: 2',
'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',
'Programming Language :: C',
'Intended Audience :: Developers',
'Topic :: Software Development :: Libraries :: Python Modules',
'Topic :: Multimedia :: Sound/Audio :: Speech'
],
license='BSD',
keywords='sphinxbase pocketsphinx',
test_suite='tests',
include_package_data=True,
zip_safe=False
)