Skip to content
Permalink
Browse files

Compiling cew on Mac OS X + Windows. Docs.

  • Loading branch information...
Alberto Pettarin
Alberto Pettarin committed Jul 19, 2016
1 parent a1c8ddd commit 7eb1bc51fa620021f627a8c7930589f22f1fbd2d
Showing with 159 additions and 15 deletions.
  1. +1 −0 MANIFEST.in
  2. +0 −8 aeneas/diagnostics.py
  3. +1 −1 debian/changelog
  4. +1 −1 docs/source/changelog.rst
  5. +108 −3 setup.py
  6. BIN thirdparty/espeak.lib
  7. +48 −2 wiki/INSTALL.md
@@ -14,6 +14,7 @@ prune docs/build
include CHANGELOG
include LICENSE
recursive-include licenses *
include output/.gitignore
include README.md
include README.rst
include requirements.txt
@@ -227,16 +227,8 @@ def check_cew(cls):
Return ``True`` on failure and ``False`` on success.
For those OSes where ``cew`` is not available,
print a warning and return ``False`` (success).
:rtype: bool
"""
if not (gf.is_linux() or gf.is_osx()):
gf.print_warning(u"aeneas.cew NOT AVAILABLE")
gf.print_info(u" The Python C Extension cew is not available for your OS")
gf.print_info(u" You can still run aeneas but it will be a bit slower (than Linux)")
return False
if gf.can_run_c_extension("cew"):
gf.print_success(u"aeneas.cew COMPILED")
return False
@@ -4,7 +4,7 @@ aeneas (1.5.1) stable; urgency=medium
* Added rconf parameters to prevent running a single C extension
* Better EAF output
* Code improvements
* Extension cew compiled for both Linux and Mac OS X
* Extension cew compiled for Mac OS X and Windows
* Added links to installers for Mac OS X and Windows in the documentation

-- alberto <alberto@nievo> Mon, 18 Jul 2016 10:21:51 +0200
@@ -15,7 +15,7 @@ v1.5.1 (2016-07-??)
#. Removed unused keys from ``JobConfiguration`` and related source files
#. Moved import statements for ``lxml`` and ``bs4`` inside the functions actually using them (better isolation for future purposes)
#. Fixed a numerical issue in ``dtw.py`` by explicit stating ``dtype=int`` in ``centers`` initializer, pure Python code only
#. Extension ``cew`` compiled in both Linux and Mac OS X
#. Extension ``cew`` compiled for Mac OS X and Windows
#. Added links to installers for Mac OS X and Windows in the documentation

v1.5.0.3 (2016-04-23)
111 setup.py
@@ -8,6 +8,7 @@
from setuptools import setup, Extension
import io
import os
import shutil
import sys

__author__ = "Alberto Pettarin"
@@ -21,6 +22,80 @@
__email__ = "aeneas@readbeyond.it"
__status__ = "Production"

def prepare_cew_for_windows():
"""
Copy files needed to compile the C extension cew on Windows.
In a glorious day, when Windows will offer a decent support
for Python and shared libraries,
all this mess will be unnecessary and it should be removed.
May that day come soon.
Return ``True`` if successful, ``False`` otherwise.
:rtype: bool
"""
try:
# copy espeak_sapi.dll to C:\Windows\System32\espeak.dll
espeak_dll_dst_path = "C:\\Windows\\System32\\espeak.dll"
espeak_dll_src_paths = [
"C:\\aeneas\\eSpeak\\espeak_sapi.dll",
"C:\\sync\\eSpeak\\espeak_sapi.dll",
"C:\\Program Files\\eSpeak\\espeak_sapi.dll",
"C:\\Program Files (x86)\\eSpeak\\espeak_sapi.dll",
]
if os.path.exists(espeak_dll_dst_path):
print("[INFO] Found eSpeak DLL in %s" % espeak_dll_dst_path)
else:
found = False
copied = False
for src_path in espeak_dll_src_paths:
if os.path.exists(src_path):
found = True
print("[INFO] Copying eSpeak DLL from %s into %s" % (src_path, espeak_dll_dst_path))
try:
shutil.copyfile(src_path, espeak_dll_dst_path)
copied = True
print("[INFO] Copied eSpeak DLL")
except:
pass
break
if not found:
print("[WARN] Unable to find the eSpeak DLL, probably because you installed eSpeak in a non-standard location.")
print("[WARN] If you want to compile the C extension cew,")
print("[WARN] please copy espeak_sapi.dll from your eSpeak directory into %s" % espeak_dll_dst_path)
print("[WARN] and run the aeneas setup again.")
return False
elif not copied:
print("[WARN] Unable to copy the eSpeak DLL, probably because you are not running with admin privileges.")
print("[WARN] If you want to compile the C extension cew,")
print("[WARN] please copy espeak_sapi.dll from your eSpeak directory into %s" % espeak_dll_dst_path)
print("[WARN] and run the aeneas setup again.")
return False

# copy thirdparty/espeak.lib to $PYTHON\libs\espeak.lib
espeak_lib_src_path = os.path.join(os.path.dirname(__file__), "thirdparty", "espeak.lib")
espeak_lib_dst_path = os.path.join(sys.prefix, "libs", "espeak.lib")
if os.path.exists(espeak_lib_dst_path):
print("[INFO] Found eSpeak LIB in %s" % espeak_lib_dst_path)
else:
try:
print("[INFO] Copying eSpeak LIB into %s" % espeak_lib_dst_path)
shutil.copyfile(espeak_lib_src_path, espeak_lib_dst_path)
print("[INFO] Copied eSpeak LIB")
except:
print("[WARN] Unable to copy the eSpeak LIB, probably because you are not running with admin privileges.")
print("[WARN] If you want to compile the C extension cew,")
print("[WARN] please copy espeak.lib from the thirdparty directory into %s" % espeak_lib_dst_path)
print("[WARN] and run the aeneas setup again.")
return False

# if here, we have completed the setup, return True
return True
except Exception as e:
print("[WARN] Unexpected exception while preparing cew: %s" % e)
return False

try:
from numpy import get_include
from numpy.distutils import misc_util
@@ -30,8 +105,12 @@
print("[INFO] $ sudo pip install numpy")
sys.exit(1)

WITHOUT_CEW = "--without-cew" in sys.argv
if WITHOUT_CEW:
sys.argv.remove("--without-cew")
IS_LINUX = (os.name == "posix") and (os.uname()[0] == "Linux")
IS_OSX = (os.name == "posix") and (os.uname()[0] == "Darwin")
IS_WINDOWS = os.name == "nt"

SHORT_DESCRIPTION = "aeneas is a Python/C library and a set of tools to automagically synchronize audio and text (aka forced alignment)"

@@ -66,9 +145,35 @@
#EXTENSIONS = [EXTENSION_CDTW, EXTENSION_CMFCC, EXTENSION_CWAVE]

EXTENSIONS = [EXTENSION_CDTW, EXTENSION_CMFCC]
if IS_LINUX or IS_OSX:
# cew is available only for Linux and Mac OS X at the moment
EXTENSIONS.append(EXTENSION_CEW)
if WITHOUT_CEW:
print("[INFO] ******************************************************************")
print("[INFO] The user specified the --without-cew switch: not building cew")
print("[INFO] ******************************************************************")
else:
if IS_LINUX:
EXTENSIONS.append(EXTENSION_CEW)
elif IS_OSX:
print("[INFO] *********************************************************************************************")
print("[INFO] Compiling C extension cew on Mac OS X is experimental.")
print("[INFO] Before installing aeneas with cew, you must run:")
print("[INFO] $ brew update && brew upgrade --cleanup espeak")
print("[INFO] to run the new brew formula installing libespeak, the library version of espeak.")
print("[INFO] If you experience problems, disable cew compilation specifying the --without-cew switch.")
print("[INFO] Please see the aeneas installation documentation for details.")
print("[INFO] *********************************************************************************************")
EXTENSIONS.append(EXTENSION_CEW)
elif IS_WINDOWS:
print("[INFO] *********************************************************************************************")
print("[INFO] Compiling C extension cew on Windows is experimental.")
print("[INFO] If you experience problems, disable cew compilation specifying the --without-cew switch.")
print("[INFO] Please see the aeneas installation documentation for details.")
print("[INFO] *********************************************************************************************")
if prepare_cew_for_windows():
EXTENSIONS.append(EXTENSION_CEW)
else:
print("[WARN] Unable to complete C extension cew setup, not compiling it.")
else:
print("[INFO] Extension cew is not available for your OS")

setup(
name="aeneas",
BIN +7.65 KB thirdparty/espeak.lib
Binary file not shown.
@@ -85,6 +85,32 @@ Please note that on Windows it is recommended to run **aeneas**
with Python 2.7, since compiling the C extensions on Python 3.4 or 3.5
requires [a complex setup process](http://stackoverflow.com/questions/29909330/microsoft-visual-c-compiler-for-python-3-4).

#### Solving Errors When Compiling ``cew``

Compilation of the Python C extension ``cew`` on Windows is experimental,
and it requires the following files:

* ``espeak_sapi.dll`` from the eSpeak installation directory must be copied into
``C:\Windows\System32\espeak.dll`` (**NOTE: file renamed!**), and
* ``espeak.lib`` from the ``thirdparty/`` directory of this repository must be copied into
``PYTHONDIR\libs\espeak.lib``, where ``PYTHONDIR`` is the directory where Python is installed,
for example ``C:\Python27``.

The ``setup.py`` script will attempt to identify and/or copy these two files,
but it might fail if you installed eSpeak in a non-standard location or
if you are not running with admin privileges.
In both cases, to install **aeneas** with ``cew`` compiled,
you can manually copy the above two files into their expected locations listed above,
and run the **aeneas** setup again.

If something goes wrong with ``cew`` while installing **aeneas**,
you can disable the C extension ``cew``
specifying the ``--without-cew`` flag:

```bash
python setup.py build_ext --inplace --without-cew
```

## Mac OS X

### All-in-one Installer
@@ -126,9 +152,10 @@ Feel free to jump to step 9 if you already have
```

**NOTE**: if you installed ``espeak`` before 2016-07-18,
please uninstall it and install it again.
please update brew and upgrade the espeak formula
(``brew update && brew upgrade --cleanup espeak``).
This way you will benefit from the ``aeneas.cew`` extension,
which relies on the presence of the ``libespeak`` shared library in your system,
which requires the presence of the ``libespeak`` shared library in your system,
added to the ``brew`` formula on that date.

5. Install Python:
@@ -181,4 +208,23 @@ Feel free to jump to step 9 if you already have
(Optional: $ sudo pip install pafy)
```

#### Solving Errors When Compiling ``cew``

Compilation of the Python C extension ``cew`` on Mac OS X is experimental,
and it requires the new brew formula installing ``libespeak``, the library version of eSpeak.
You can get it with:

```bash
brew update && brew upgrade --cleanup espeak
```

If something goes wrong with ``cew`` while installing **aeneas**,
you can disable the C extension ``cew``
specifying the ``--without-cew`` flag:

```bash
python setup.py build_ext --inplace --without-cew
```



0 comments on commit 7eb1bc5

Please sign in to comment.
You can’t perform that action at this time.