Skip to content

Commit 32ff522

Browse files
committed
Merge pull request #30 from readbeyond/devel
PyPI setup.py and check_dependencies.py back
2 parents be8166d + c983517 commit 32ff522

File tree

4 files changed

+220
-11
lines changed

4 files changed

+220
-11
lines changed

check_dependencies.py

Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
1+
#!/usr/bin/env python
2+
# coding=utf-8
3+
4+
"""
5+
Check whether the setup of aeneas was successful.
6+
7+
Requires the audio file aeneas/tools/res/audio.mp3
8+
9+
Running this script makes sense only
10+
if you git-cloned the original GitHub repository
11+
and/or if you are interested in contributing to the
12+
development of aeneas.
13+
"""
14+
15+
import os
16+
import tempfile
17+
18+
__author__ = "Alberto Pettarin"
19+
__copyright__ = """
20+
Copyright 2012-2013, Alberto Pettarin (www.albertopettarin.it)
21+
Copyright 2013-2015, ReadBeyond Srl (www.readbeyond.it)
22+
Copyright 2015, Alberto Pettarin (www.albertopettarin.it)
23+
"""
24+
__license__ = "GNU AGPL 3"
25+
__version__ = "1.3.2"
26+
__email__ = "[email protected]"
27+
__status__ = "Production"
28+
29+
SETUP_COMMAND = "'python setup.py build_ext --inplace'"
30+
31+
def on_error(msg):
32+
print "[ERRO] %s" % msg
33+
34+
def on_info(msg):
35+
print "[INFO] %s" % msg
36+
37+
def on_warning(msg):
38+
print "[WARN] %s" % msg
39+
40+
def get_abs_path(rel_path):
41+
file_dir = os.path.dirname(__file__)
42+
return os.path.join(file_dir, rel_path)
43+
44+
def step1():
45+
on_info("Test 1/7 (import)...")
46+
try:
47+
on_info(" Trying to import package aeneas...")
48+
import aeneas
49+
on_info(" Trying to import package aeneas... succeeded.")
50+
return True
51+
except ImportError:
52+
on_error(" Unable to import package aeneas.")
53+
on_error(" Check that you have installed the following Python (2.7.x) packages:")
54+
on_error(" 1. BeautifulSoup")
55+
on_error(" 2. lxml")
56+
on_error(" 3. numpy")
57+
except:
58+
pass
59+
return False
60+
61+
def step2():
62+
on_info("Test 2/7 (ffprobe)...")
63+
try:
64+
on_info(" Trying to call ffprobe...")
65+
from aeneas.ffprobewrapper import FFPROBEWrapper
66+
file_path = get_abs_path("aeneas/tools/res/audio.mp3")
67+
prober = FFPROBEWrapper()
68+
properties = prober.read_properties(file_path)
69+
on_info(" Trying to call ffprobe... succeeded.")
70+
return True
71+
except:
72+
on_error(" Unable to call ffprobe.")
73+
on_error(" Please make sure you have ffprobe installed correctly and that it is in your $PATH.")
74+
return False
75+
76+
def step3():
77+
on_info("Test 3/7 (ffmpeg)...")
78+
try:
79+
on_info(" Trying to call ffmpeg...")
80+
from aeneas.ffmpegwrapper import FFMPEGWrapper
81+
import aeneas.globalfunctions as gf
82+
input_file_path = get_abs_path("aeneas/tools/res/audio.mp3")
83+
handler, output_file_path = tempfile.mkstemp(suffix=".wav")
84+
converter = FFMPEGWrapper()
85+
result = converter.convert(input_file_path, output_file_path)
86+
gf.delete_file(handler, output_file_path)
87+
if result:
88+
on_info(" Trying to call ffmpeg... succeeded.")
89+
return True
90+
else:
91+
on_error(" Unable to call ffmpeg.")
92+
on_error(" Please make sure you have ffmpeg installed correctly and that it is in your $PATH.")
93+
except:
94+
on_error(" Unable to call ffmpeg.")
95+
on_error(" Please make sure you have ffmpeg installed correctly and that it is in your $PATH.")
96+
return False
97+
98+
def step4():
99+
on_info("Test 4/7 (espeak)...")
100+
try:
101+
on_info(" Trying to call espeak...")
102+
from aeneas.espeakwrapper import ESPEAKWrapper
103+
from aeneas.language import Language
104+
import aeneas.globalfunctions as gf
105+
text = u"From fairest creatures we desire increase,"
106+
language = Language.EN
107+
handler, output_file_path = tempfile.mkstemp(suffix=".wav")
108+
espeak = ESPEAKWrapper()
109+
result = espeak.synthesize_single(
110+
text,
111+
language,
112+
output_file_path,
113+
force_pure_python=True
114+
)
115+
gf.delete_file(handler, output_file_path)
116+
if result:
117+
on_info(" Trying to call espeak... succeeded.")
118+
return True
119+
else:
120+
on_error(" Unable to call espeak.")
121+
on_error(" Please make sure you have espeak installed correctly and that it is in your $PATH.")
122+
except:
123+
on_error(" Unable to call espeak.")
124+
on_error(" Please make sure you have espeak installed correctly and that it is in your $PATH.")
125+
return False
126+
127+
def stepC1():
128+
on_info("Test 5/7 (cdtw)...")
129+
try:
130+
import aeneas.cdtw
131+
on_info(" Python C Extension cdtw correctly loaded")
132+
return True
133+
except:
134+
on_warning(" Unable to load Python C Extension cdtw")
135+
on_warning(" You can still run aeneas, but it will much slower")
136+
on_warning(" Try running %s to compile the cdtw module" % SETUP_COMMAND)
137+
return False
138+
139+
def stepC2():
140+
on_info("Test 6/7 (cmfcc)...")
141+
try:
142+
import aeneas.cmfcc
143+
on_info(" Python C Extension cmfcc correctly loaded")
144+
return True
145+
except:
146+
on_warning(" Unable to load Python C Extension cmfcc")
147+
on_warning(" You can still run aeneas, but it will be a bit slower")
148+
on_warning(" Try running %s to compile the cmfcc module" % SETUP_COMMAND)
149+
return False
150+
151+
def stepC3():
152+
on_info("Test 7/7 (cew)...")
153+
if not ((os.name == "posix") and (os.uname()[0] == "Linux")):
154+
on_info(" Python C Extension cew is not available for your OS")
155+
on_info(" You can still run aeneas, but it will be a bit slower than Linux")
156+
return True
157+
try:
158+
import aeneas.cew
159+
on_info(" Python C Extension cew correctly loaded")
160+
return True
161+
except:
162+
on_warning(" Unable to load Python C Extension cew")
163+
on_warning(" You can still run aeneas, but it will be a bit slower")
164+
on_warning(" Try running %s to compile the cew module" % SETUP_COMMAND)
165+
return False
166+
167+
def main():
168+
if not step1():
169+
return
170+
171+
if not step2():
172+
return
173+
174+
if not step3():
175+
return
176+
177+
if not step4():
178+
return
179+
180+
has_cdtw = stepC1()
181+
has_cmfcc = stepC2()
182+
has_cew = stepC3()
183+
184+
if has_cdtw and has_cmfcc and has_cew:
185+
on_info("Congratulations, all dependencies are met and core C extensions are available.")
186+
else:
187+
on_warning("All dependencies are met, but at least one core C extension has not been compiled.")
188+
on_warning("Try running %s to compile the C extensions." % SETUP_COMMAND)
189+
190+
on_info("Enjoy running aeneas!")
191+
192+
193+
194+
if __name__ == '__main__':
195+
main()
196+
197+
198+

docs/source/changelog.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ v1.3.2 (2015-11-11)
88
#. Added ``is_text_file_transliterate_map`` parameter to read a transliteration map from file and apply it to the input text
99
#. Added ``thirdparty/transliteration.map`` sample transliteration map (courtesy of Steve Gallagher and Richard Margetts)
1010
#. Edited ``README.md``, stating the optional dependency from ``pafy``
11-
#. Renamed ``check_dependencies.sh`` into ``aeneas_check_setup.py``
11+
#. Renamed ``check_dependencies.py`` into ``aeneas_check_setup.py``
1212

1313
v1.3.1.1 (2015-11-03)
1414
---------------------

requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
BeautifulSoup
2-
lxml
3-
numpy
1+
BeautifulSoup>=3.0
2+
lxml>=3.0
3+
numpy>=1.9

setup.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@
44
"""
55
Set aeneas package up
66
"""
7-
from numpy import get_include
8-
from numpy.distutils import misc_util
7+
98
from setuptools import setup, Extension
10-
import os
119

1210
__author__ = "Alberto Pettarin"
1311
__copyright__ = """
@@ -20,26 +18,37 @@
2018
__email__ = "[email protected]"
2119
__status__ = "Production"
2220

21+
EXTENSIONS = []
22+
INCLUDE_DIRS = []
23+
#try:
24+
from numpy import get_include
25+
from numpy.distutils import misc_util
26+
import os
27+
INCLUDE_DIRS = [misc_util.get_numpy_include_dirs()]
2328
EXTENSION_CDTW = Extension("aeneas.cdtw", ["aeneas/cdtw.c"], include_dirs=[get_include()])
2429
EXTENSION_CEW = Extension("aeneas.cew", ["aeneas/cew.c"], libraries=["espeak"])
2530
EXTENSION_CMFCC = Extension("aeneas.cmfcc", ["aeneas/cmfcc.c"], include_dirs=[get_include()])
26-
2731
EXTENSIONS = [EXTENSION_CDTW, EXTENSION_CMFCC]
2832
if (os.name == "posix") and (os.uname()[0] == "Linux"):
2933
# cew is available only for Linux at the moment
3034
EXTENSIONS.append(EXTENSION_CEW)
35+
#except:
36+
# pass
3137

3238
setup(
3339
name="aeneas",
3440
packages=["aeneas", "aeneas.tools"],
35-
version="1.3.2",
41+
package_data={"aeneas": ["res/*", "speak_lib.h"], "aeneas.tools": ["res/*"]},
42+
version="1.3.2.6",
3643
description="aeneas is a Python library and a set of tools to automagically synchronize audio and text",
3744
author="Alberto Pettarin",
3845
author_email="[email protected]",
3946
url="https://github.com/readbeyond/aeneas",
4047
license="GNU Affero General Public License v3 (AGPL v3)",
4148
long_description=open("README.txt", "r").read(),
42-
install_requires=["BeautifulSoup", "lxml", "numpy"],
49+
setup_requires=["numpy>=1.9"],
50+
install_requires=["BeautifulSoup>=3.0", "lxml>=3.0", "numpy>=1.9"],
51+
extras_require={"pafy": ["pafy>=0.3"]},
4352
keywords=[
4453
"CSV",
4554
"DTW",
@@ -78,8 +87,10 @@
7887
"License :: OSI Approved :: GNU Affero General Public License v3",
7988
"Natural Language :: English",
8089
"Programming Language :: Python",
90+
"Programming Language :: Python :: 2",
91+
"Programming Language :: Python :: 2.7",
8192
"Topic :: Software Development :: Libraries :: Python Modules"
8293
],
8394
ext_modules=EXTENSIONS,
84-
include_dirs=[misc_util.get_numpy_include_dirs()]
95+
include_dirs=INCLUDE_DIRS,
8596
)

0 commit comments

Comments
 (0)