Skip to content
This repository was archived by the owner on Jun 27, 2023. It is now read-only.

Commit a6083af

Browse files
committed
Fixed Makefile and setup.py
1 parent 4a10460 commit a6083af

File tree

3 files changed

+76
-19
lines changed

3 files changed

+76
-19
lines changed

Makefile

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,12 @@ build_sdist: clean
4444
$(PYTHON2_X86) setup.py sdist --formats=zip,gztar,bztar
4545

4646
build_egg_py2_x86: clean
47-
# Workaround fix inclusion of python modules in the distribution
48-
$(PYTHON2_X86) setup.py bdist_egg build
4947
$(PYTHON2_X86) setup.py bdist_egg build
5048

5149
build_egg_py3_x86: clean
5250
$(PYTHON3_X86) setup.py bdist_egg build
5351

5452
build_egg_py2_x64: clean
55-
# Workaround fix inclusion of python modules in the distribution
56-
$(PYTHON2_X64) setup.py bdist_egg build
5753
$(PYTHON2_X64) setup.py bdist_egg build
5854

5955
build_egg_py3_x64: clean
@@ -123,16 +119,12 @@ upload_sdist: clean
123119
$(PYTHON2_X86) setup.py sdist --formats=zip,gztar,bztar upload
124120

125121
upload_egg_py2_x86: clean
126-
# Workaround fix inclusion of python modules in the distribution
127-
$(PYTHON2_X86) setup.py bdist_egg build
128122
$(PYTHON2_X86) setup.py bdist_egg upload
129123

130124
upload_egg_py3_x86: clean
131125
$(PYTHON3_X86) setup.py bdist_egg upload
132126

133127
upload_egg_py2_x64: clean
134-
# Workaround fix inclusion of python modules in the distribution
135-
$(PYTHON2_X64) setup.py bdist_egg build
136128
$(PYTHON2_X64) setup.py bdist_egg upload
137129

138130
upload_egg_py3_x64: clean

README.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Pocketsphinx Python
2323
:alt: License
2424

2525
Pocketsphinx is part of the `CMU Sphinx <http://cmusphinx.sourceforge.net>`__ Open Source Toolkit For Speech Recognition.
26+
2627
This package provides python interface to CMU `Sphinxbase <https://github.com/cmusphinx/sphinxbase>`__ and `Pocketsphinx <https://github.com/cmusphinx/pocketsphinx>`__ libraries created with `SWIG <http://www.swig.org>`__ and `Setuptools <https://setuptools.readthedocs.io>`__.
2728

2829
===================

setup.py

Lines changed: 75 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
11
#!/usr/bin/env python
22
import os
33
import sys
4-
from shutil import copy, copytree, rmtree, ignore_patterns
4+
from shutil import copy, copytree, ignore_patterns
55
from glob import glob
6+
from distutils.command.build import build as _build
67
try:
78
from setuptools import setup, Extension
8-
except:
9+
from setuptools.command.install import install as _install
10+
from setuptools.command.bdist_egg import bdist_egg as _bdist_egg
11+
except ImportError:
912
from distutils.core import setup
1013
from distutils.extension import Extension
14+
from distutils.command.install import install as _install
15+
from distutils.command.bdist_egg import bdist_egg as _bdist_egg
16+
17+
if sys.platform.startswith('win'):
18+
from distutils.command.bdist_msi import bdist_msi as _bdist_msi
19+
from distutils.command.bdist_wininst import bdist_wininst as _bdist_wininst
1120

1221
extra_compile_args = []
1322
extra_link_args = []
@@ -110,18 +119,72 @@
110119
['-outdir', 'pocketsphinx']
111120
)
112121

113-
rmtree('pocketsphinx/data', True)
114-
rmtree('pocketsphinx/model', True)
115-
copytree('deps/pocketsphinx/model/en-us',
116-
'pocketsphinx/model',
117-
ignore=ignore_patterns('en-us-phone.lm.bin'))
118-
os.makedirs('pocketsphinx/data')
119-
copy('deps/pocketsphinx/test/data/goforward.raw',
120-
'pocketsphinx/data/goforward.raw')
122+
if not os.path.exists(os.path.join(os.path.dirname(__file__), 'pocketsphinx/model')):
123+
copytree(os.path.join(os.path.dirname(__file__), 'deps/pocketsphinx/model/en-us'),
124+
os.path.join(os.path.dirname(__file__), 'pocketsphinx/model'),
125+
ignore=ignore_patterns('en-us-phone.lm.bin'))
126+
if not os.path.exists(os.path.join(os.path.dirname(__file__), 'pocketsphinx/data')):
127+
os.makedirs(os.path.join(os.path.dirname(__file__), 'pocketsphinx/data'))
128+
copy(os.path.join(os.path.dirname(__file__), 'deps/pocketsphinx/test/data/goforward.raw'),
129+
os.path.join(os.path.dirname(__file__), 'pocketsphinx/data/goforward.raw'))
130+
131+
132+
class build(_build):
133+
def run(self):
134+
self.run_command('build_ext')
135+
return _build.run(self)
136+
137+
138+
class install(_install):
139+
def run(self):
140+
self.run_command('build_ext')
141+
return _install.run(self)
142+
143+
144+
class bdist_egg(_bdist_egg):
145+
def run(self):
146+
self.run_command('build_ext')
147+
return _bdist_egg.run(self)
148+
149+
150+
cmdclass = {
151+
'build': build,
152+
'install': install,
153+
'bdist_egg': bdist_egg
154+
}
155+
156+
157+
try:
158+
from wheel.bdist_wheel import bdist_wheel as _bdist_wheel
159+
except ImportError:
160+
pass
161+
else:
162+
class bdist_wheel(_bdist_wheel):
163+
def run(self):
164+
self.run_command('build_ext')
165+
return _bdist_wheel.run(self)
166+
167+
cmdclass['bdist_wheel'] = bdist_wheel
168+
169+
170+
if sys.platform.startswith('win'):
171+
class bdist_msi(_bdist_msi):
172+
def run(self):
173+
self.run_command('build_ext')
174+
return _bdist_msi.run(self)
175+
176+
class bdist_wininst(_bdist_wininst):
177+
def run(self):
178+
self.run_command('build_ext')
179+
return _bdist_wininst.run(self)
180+
181+
cmdclass['bdist_msi'] = bdist_msi
182+
cmdclass['bdist_wininst'] = bdist_wininst
183+
121184

122185
setup(
123186
name='pocketsphinx',
124-
version='0.1.1',
187+
version='0.1.3',
125188
description='Python interface to CMU Sphinxbase and Pocketsphinx libraries',
126189
long_description=open('README.rst').read(),
127190
author='Dmitry Prazdnichnov',
@@ -164,6 +227,7 @@
164227
extra_link_args=extra_link_args
165228
)
166229
],
230+
cmdclass=cmdclass,
167231
classifiers=[
168232
'Development Status :: 2 - Pre-Alpha',
169233
'Operating System :: Microsoft :: Windows',

0 commit comments

Comments
 (0)