Uh oh!
There was an error while loading. Please reload this page.
forked from bambocher/pocketsphinx-python
- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup.py
More file actions
Latest commit
322 lines (276 loc) · 10 KB
/
Copy pathsetup.py
File metadata and controls
322 lines (276 loc) · 10 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
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
#!/usr/bin/env python
importos
importsys
fromshutilimportcopy, copytree, ignore_patterns
fromglobimportglob
fromdistutilsimportlog
fromdistutils.command.buildimportbuildas_build
try:
fromsetuptoolsimportsetup, Extension
fromsetuptools.command.installimportinstallas_install
fromsetuptools.command.bdist_eggimportbdist_eggas_bdist_egg
exceptImportError:
fromdistutils.coreimportsetup
fromdistutils.extensionimportExtension
fromdistutils.command.installimportinstallas_install
fromdistutils.command.bdist_eggimportbdist_eggas_bdist_egg
ifsys.platform.startswith('win'):
fromdistutils.command.bdist_msiimportbdist_msias_bdist_msi
fromdistutils.command.bdist_wininstimportbdist_wininstas_bdist_wininst
ifsys.argv[-1] =='publish':
os.system('python setup.py sdist')
os.system('twine upload dist/*')
os.system('rm -rf dist')
os.system('rm -rf *.egg-info')
sys.exit()
def_find_vcvarsall(version):
vsbase=msvc9compiler.VS_BASE%version
productdir=None
ifversion!=9.0:
try:
productdir=msvc9compiler.Reg.get_value(r"%s\Setup\VC"%vsbase,
"productdir")
exceptKeyError:
log.debug("Unable to find productdir in registry")
ifnotproductdirornotos.path.isdir(productdir):
toolskey="VS%0.f0COMNTOOLS"%version
toolsdir=os.environ.get(toolskey, None)
iftoolsdirandos.path.isdir(toolsdir):
productdir=os.path.join(toolsdir, os.pardir, os.pardir, "VC")
productdir=os.path.abspath(productdir)
ifnotos.path.isdir(productdir):
log.debug("%s is not a valid directory"%productdir)
returnNone
else:
log.debug("Env var %s is not set or invalid"%toolskey)
ifnotproductdir:
log.debug("No productdir found")
returnNone
vcvarsall=os.path.join(productdir, "vcvarsall.bat")
ifos.path.isfile(vcvarsall):
returnvcvarsall
log.debug("Unable to find vcvarsall.bat")
returnNone
try:
fromdistutilsimportmsvc9compiler
msvc9compiler.find_vcvarsall=_find_vcvarsall
exceptImportError:
pass
extra_compile_args= []
extra_link_args= []
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')
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)
]
ifsys.platform.startswith('win'):
sb_include_dirs.append('deps/sphinxbase/include/win32')
extra_compile_args.extend([
'/wd4244',
'/wd4267',
'/wd4197',
'/wd4090',
'/wd4018',
'/wd4311',
'/wd4312',
'/wd4334',
'/wd4477',
'/wd4996'
])
extra_link_args.append('/ignore:4197')
elifsys.platform.startswith('darwin'):
sb_include_dirs.append('deps/sphinxbase/include/android')
extra_compile_args.extend([
'-Wno-macro-redefined',
'-Wno-sign-compare',
'-Wno-logical-op-parentheses'
])
elifsys.platform.startswith('linux'):
sb_include_dirs.append('deps/sphinxbase/include/android')
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', '-threads'] +
['-I'+hforhinsb_include_dirs] +
['-Ideps/sphinxbase/swig'] +
['-outdir', 'sphinxbase']
)
ps_swig_opts= (
['-modern', '-threads'] +
['-I'+hforhinsb_include_dirs+ps_include_dirs] +
['-Ideps/sphinxbase/swig'] +
['-outdir', 'pocketsphinx']
)
ifnotos.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'))
ifnotos.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'))
classbuild(_build):
defrun(self):
self.run_command('build_ext')
return_build.run(self)
classinstall(_install):
defrun(self):
self.run_command('build_ext')
return_install.run(self)
cmdclass= {
'build': build,
'install': install,
}
try:
fromwheel.bdist_wheelimportbdist_wheelas_bdist_wheel
exceptImportError:
pass
else:
classbdist_wheel(_bdist_wheel):
defrun(self):
self.run_command('build_ext')
return_bdist_wheel.run(self)
cmdclass['bdist_wheel'] =bdist_wheel
ifsys.platform.startswith('win'):
classbdist_wininst(_bdist_wininst):
defrun(self):
self.run_command('build_ext')
return_bdist_wininst.run(self)
cmdclass['bdist_wininst'] =bdist_wininst
ext_modules= [
Extension(
name='sphinxbase._sphinxbase',
sources=sb_sources,
swig_opts=sb_swig_opts,
include_dirs=sb_include_dirs,
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,
define_macros=define_macros,
extra_compile_args=extra_compile_args,
extra_link_args=extra_link_args
)
]
ifsys.platform.startswith('win'):
ext_modules.append(
Extension(
name='sphinxbase._ad_win32',
sources=['swig/sphinxbase/ad_win32.i', 'deps/sphinxbase/src/libsphinxad/ad_win32.c'],
swig_opts=sb_swig_opts,
include_dirs=sb_include_dirs,
libraries=['winmm'],
define_macros=define_macros,
extra_compile_args=extra_compile_args,
extra_link_args=extra_link_args
)
)
elifsys.platform.startswith('darwin'):
sb_include_dirs.append('/System/Library/Frameworks/OpenAL.framework/Versions/A/Headers')
ext_modules.append(
Extension(
name='sphinxbase._ad_openal',
sources=['swig/sphinxbase/ad_openal.i', 'deps/sphinxbase/src/libsphinxad/ad_openal.c'],
swig_opts=sb_swig_opts,
include_dirs=sb_include_dirs,
extra_objects=['/System/Library/Frameworks/OpenAL.framework/Versions/A/OpenAL'],
define_macros=define_macros,
extra_compile_args=extra_compile_args,
extra_link_args=extra_link_args
)
)
elifsys.platform.startswith('linux'):
ext_modules.extend([
Extension(
name='sphinxbase._ad_pulse',
sources=['swig/sphinxbase/ad_pulse.i', 'deps/sphinxbase/src/libsphinxad/ad_pulse.c'],
swig_opts=sb_swig_opts,
include_dirs=sb_include_dirs,
libraries=['pulse', 'pulse-simple'],
define_macros=define_macros,
extra_compile_args=extra_compile_args,
extra_link_args=extra_link_args
),
Extension(
name='sphinxbase._ad_alsa',
sources=['swig/sphinxbase/ad_alsa.i', 'deps/sphinxbase/src/libsphinxad/ad_alsa.c'],
swig_opts=sb_swig_opts,
include_dirs=sb_include_dirs,
libraries=['asound'],
define_macros=define_macros,
extra_compile_args=extra_compile_args,
extra_link_args=extra_link_args
)
])
setup(
name='pocketsphinx2',
version='0.1.15',
description='Python interface to CMU Sphinxbase and Pocketsphinx libraries (fixed MacOS and Linux (Ubuntu 18.04) installation problem.If you wanna install, the original packaget maybe the right choose, if you have problems with original packaget, then try out this one',
long_description=open('README.md').read(),
long_description_content_type='text/markdown',
author='Dmitry Prazdnichnov',
author_email='dmitry@prazdnichnov.name',
maintainer='Dmitry Prazdnichnov',
maintainer_email='dmitry@prazdnichnov.name',
url='https://github.com/bambocher/pocketsphinx-python',
download_url='https://pypi.org/project/pocketsphinx/#files',
packages=['sphinxbase', 'pocketsphinx'],
ext_modules=ext_modules,
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.5',
'Programming Language :: Python :: 3.6',
'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
)