forked from cmusphinx/pocketsphinx-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
192 lines (165 loc) · 4.88 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
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
#!/usr/bin/env python
# encoding: utf-8
"""
Supported Platforms
-------------------
- Windows 7
- Windows 8
- Ubuntu 14.10
Dependencies
------------
* `Python <https://www.python.org/downloads/>`_
* `Swig <http://www.swig.org/download.html>`_
* `Microsoft Visual C++ Compiler for Python 2.7 <http://aka.ms/vcpython27>`_
Install
-------
.. code:: bash
pip install pocketsphinx
or
--
.. code:: bash
git clone https://github.com/bambocher/pocketsphinx-python.git
cd pocketsphinx-python
python setup.py install
Import
------
.. code:: python
from sphinxbase.sphinxbase import Config
from pocketsphinx.pocketsphinx import Decoder
"""
import sys
from glob import glob
try:
from setuptools import setup, Extension
from distutils.command.build import build
from setuptools.command.install import install
except ImportError:
from distutils.core import setup
from distutils.extension import Extension
from distutils.command.build import build
from distutils.command.install import install
PY2 = sys.version_info[0] == 2
libsphinxbase = (
glob('sphinxbase/src/libsphinxbase/lm/*.c') +
glob('sphinxbase/src/libsphinxbase/feat/*.c') +
glob('sphinxbase/src/libsphinxbase/util/*.c') +
glob('sphinxbase/src/libsphinxbase/fe/*.c')
)
libpocketsphinx = glob('pocketsphinx/src/libpocketsphinx/*.c')
sb_include_dirs = ['sphinxbase/include', 'sphinxbase/include/sphinxbase']
ps_include_dirs = ['pocketsphinx/include']
libraries = []
define_macros = [
('SPHINXBASE_EXPORTS', None),
('POCKETSPHINX_EXPORTS', None),
('HAVE_CONFIG_H', None),
('_CRT_SECURE_NO_DEPRECATE', None),
('_USRDLL', None),
('SPHINXDLL', None)
]
extra_compile_args = []
if sys.platform.startswith('linux'):
sb_include_dirs.extend(['include'])
extra_compile_args.extend([
'-Wno-unused-label',
'-Wno-strict-prototypes',
'-Wno-parentheses',
'-Wno-unused-but-set-variable',
'-Wno-unused-variable',
'-Wno-unused-result'
])
elif sys.platform.startswith('win'):
sb_include_dirs.extend(['sphinxbase/include/win32'])
define_macros.extend([
('WIN32', None),
('_WINDOWS', None),
('YY_NO_UNISTD_H', None)
])
extra_compile_args.extend([
'/wd4244',
'/wd4267',
'/wd4197',
'/wd4090',
'/wd4018'
])
elif sys.platform.startswith('darwin'):
sb_include_dirs.extend(['include'])
else:
pass
sb_sources = (
libsphinxbase +
['sphinxbase/swig/sphinxbase.i']
)
ps_sources = (
libsphinxbase +
libpocketsphinx +
['pocketsphinx/swig/pocketsphinx.i']
)
swig_opts = ['-modern', '-threads']
sb_swig_opts = (
swig_opts +
['-I' + h for h in sb_include_dirs] +
['-outdir', 'sphinxbase/swig/python']
)
ps_swig_opts = (
swig_opts +
['-I' + h for h in sb_include_dirs] +
['-I' + h for h in ps_include_dirs] +
['-Isphinxbase/swig'] +
['-outdir', 'pocketsphinx/swig/python']
)
setup(
name='pocketsphinx',
version='0.0.9',
description='Python interface to CMU SphinxBase and PocketSphinx libraries',
long_description=__doc__,
author='Dmitry Prazdnichnov',
author_email='dp@bambucha.org',
maintainer='Dmitry Prazdnichnov',
maintainer_email='dp@bambucha.org',
url='https://github.com/cmusphinx/pocketsphinx-python',
download_url='https://pypi.python.org/pypi/pocketsphinx',
packages=['sphinxbase', 'pocketsphinx'],
ext_modules=[
Extension(
name='sphinxbase._sphinxbase',
sources=sb_sources,
swig_opts=sb_swig_opts,
include_dirs=sb_include_dirs,
libraries=libraries,
define_macros=define_macros,
extra_compile_args=extra_compile_args
),
Extension(
name='pocketsphinx._pocketsphinx',
sources=ps_sources,
swig_opts=ps_swig_opts,
include_dirs=sb_include_dirs + ps_include_dirs,
libraries=libraries,
define_macros=define_macros,
extra_compile_args=extra_compile_args
)
],
classifiers=[
'Development Status :: 2 - Pre-Alpha',
'License :: OSI Approved :: BSD License',
'Operating System :: Microsoft :: Windows',
'Operating System :: POSIX :: Linux',
'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',
'Programming Language :: C'
],
license='BSD',
keywords=['sphinxbase', 'pocketsphinx'],
platforms=['Windows'],
package_dir={
'sphinxbase': 'sphinxbase/swig/python',
'pocketsphinx': 'pocketsphinx/swig/python'
}
)