Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion debian/copyright
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Files: *
Copyright: 2012-2013, Alberto Pettarin (www.albertopettarin.it)
2013-2015, ReadBeyond Srl (www.readbeyond.it)
2015-2018, Alberto Pettarin (www.albertopettarin.it)
2015-2026, Alberto Pettarin (www.albertopettarin.it)
License: AGPLv3-only
The GNU Affero General Public License is a free, copyleft license for
software and other kinds of works, specifically designed to ensure
Expand Down
4 changes: 4 additions & 0 deletions docs/source/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
Changelog
=========
v1.7.3.1 (2020-05-06)
---------------------
#. Fixed spurious warnings about not using UTF-8 when "utf-8" is seen
#. Added debian packaging for python3-aeneas

v1.7.4 (2020-05-??)
-------------------
Expand Down
113 changes: 97 additions & 16 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from setuptools import setup
from setuptools.command.build_ext import build_ext as BaseBuildExtension
import os
import sys
import shutil

from setupmeta import PKG_AUTHOR
Expand Down Expand Up @@ -80,16 +81,25 @@ def prepare_cew_for_windows():

:rtype: bool
"""

try:
# copy espeak_sapi.dll to C:\Windows\System32\espeak.dll
espeak_dll_win_path = "C:\\Windows\\System32\\espeak.dll"
espeak_dll_dst_path = "aeneas\\cew\\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 USE_ESPEAKNG:
espeak_dll_win_path = "C:\\Windows\\System32\\libespeak-ng.dll"
espeak_dll_dst_path = "aeneas\\cew\\libespeak-ng.dll"
espeak_dll_src_paths = [
"C:\\Program Files\\eSpeak NG\\libespeak-ng.dll",
"C:\\Program Files (x86)\\eSpeak NG\\libespeak-ng.dll",
]
else:
espeak_dll_win_path = "C:\\Windows\\System32\\espeak.dll"
espeak_dll_dst_path = "aeneas\\cew\\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:
Expand Down Expand Up @@ -123,13 +133,20 @@ def prepare_cew_for_windows():
# so, we copy it in the current working directory from the included thirdparty\ directory
# NOTE: PREV: copy thirdparty\espeak.lib to $PYTHON\libs\espeak.lib
# NOTE: PREV: espeak_lib_dst_path = os.path.join(sys.prefix, "libs", "espeak.lib")
espeak_lib_src_path = os.path.join(os.path.dirname(__file__), "thirdparty", "espeak.lib")
espeak_lib_dst_path = os.path.join(os.path.dirname(__file__), "espeak.lib")
if USE_ESPEAKNG:
if IS_64BITS:
espeak_lib_src_path = os.path.join(os.path.dirname(__file__), "thirdparty", "libespeak-ng-x64.lib")
else:
espeak_lib_src_path = os.path.join(os.path.dirname(__file__), "thirdparty", "libespeak-ng-x86.lib")
espeak_lib_dst_path = os.path.join(os.path.dirname(__file__), "espeak-ng.lib")
else:
espeak_lib_src_path = os.path.join(os.path.dirname(__file__), "thirdparty", "espeak.lib")
espeak_lib_dst_path = os.path.join(os.path.dirname(__file__), "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)
print("[INFO] Copying eSpeak LIB from %s into %s" % (espeak_lib_src_path, espeak_lib_dst_path))
shutil.copyfile(espeak_lib_src_path, espeak_lib_dst_path)
print("[INFO] Copied eSpeak LIB")
except:
Expand All @@ -145,6 +162,55 @@ def prepare_cew_for_windows():
print("[WARN] Unexpected exception while preparing cew: %s" % e)
return False

def prepare_cew_speak_lib():
"""
Copy files needed to compile the ``cew`` Python C extension on Windows.

Return ``True`` if successful, ``False`` otherwise.

:rtype: bool
"""

try:
# NOTE: speak_lib.h is needed only while compiling the C extension, not when using it
# so, we copy it in the current working directory from the included thirdparty\ directory
if USE_ESPEAKNG:
espeak_lib_src_path = os.path.join(os.path.dirname(__file__), "thirdparty", "speak-ng_lib.h")
else:
espeak_lib_src_path = os.path.join(os.path.dirname(__file__), "thirdparty", "speak_lib.h")
espeak_lib_dst_path = os.path.join(os.path.dirname(__file__), "aeneas", "cew", "speak_lib.h")
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 from %s into %s" % (espeak_lib_src_path, 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

def get_espeak_lib():
"""
Return ``espeak-ng`` if true, ``espeak`` otherwise.

:rtype: string
"""

if USE_ESPEAKNG:
return "espeak-ng"
else:
return "espeak"


##############################################################################
#
Expand All @@ -156,6 +222,7 @@ def prepare_cew_for_windows():
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")
IS_64BITS = (sys.maxsize > 2**32)
Comment thread
danielbair marked this conversation as resolved.

# define what values of environment variables are considered equal to True
TRUE_VALUES = [
Expand All @@ -177,6 +244,7 @@ def prepare_cew_for_windows():
WITHOUT_CEW = os.getenv("AENEAS_WITH_CEW", "True") not in TRUE_VALUES
FORCE_CEW = os.getenv("AENEAS_FORCE_CEW", "False") in TRUE_VALUES
FORCE_CFW = os.getenv("AENEAS_FORCE_CFW", "False") in TRUE_VALUES
USE_ESPEAKNG = os.getenv("AENEAS_USE_ESPEAKNG", "False") in TRUE_VALUES


##############################################################################
Expand Down Expand Up @@ -224,7 +292,7 @@ def finalize_options(self):
"aeneas/cew/cew_func.c"
],
libraries=[
"espeak"
get_espeak_lib()
]
)
EXTENSION_CFW = Extension(
Expand Down Expand Up @@ -292,8 +360,15 @@ def finalize_options(self):
print("[INFO] ")
EXTENSIONS.append(EXTENSION_CEW)
else:
print("[INFO] ********************************************************************************")
print("[INFO] Specify AENEAS_USE_ESPEAKNG=True to build aeneas with espeak-ng libraries")
print("[INFO] ********************************************************************************")
print("[INFO] ")
if IS_LINUX:
EXTENSIONS.append(EXTENSION_CEW)
if prepare_cew_speak_lib():
EXTENSIONS.append(EXTENSION_CEW)
else:
print("[WARN] Unable to complete the setup for C extension cew, not building it.")
elif IS_OSX:
print("[INFO] *********************************************************************************")
print("[INFO] Compiling the C extension cew on Mac OS X is experimental.")
Expand All @@ -307,7 +382,10 @@ def finalize_options(self):
print("[INFO] Please see the aeneas installation documentation for details.")
print("[INFO] ********************************************************************************")
print("[INFO] ")
EXTENSIONS.append(EXTENSION_CEW)
if prepare_cew_speak_lib():
EXTENSIONS.append(EXTENSION_CEW)
else:
print("[WARN] Unable to complete the setup for C extension cew, not building it.")
elif IS_WINDOWS:
print("[INFO] *****************************************************************")
print("[INFO] Compiling the C extension cew on Windows is experimental.")
Expand All @@ -317,8 +395,11 @@ def finalize_options(self):
print("[INFO] Please see the aeneas installation documentation for details.")
print("[INFO] *****************************************************************")
print("[INFO] ")
if prepare_cew_for_windows():
EXTENSIONS.append(EXTENSION_CEW)
if prepare_cew_speak_lib():
if prepare_cew_for_windows():
EXTENSIONS.append(EXTENSION_CEW)
else:
print("[WARN] Unable to complete the setup for C extension cew, not building it.")
else:
print("[WARN] Unable to complete the setup for C extension cew, not building it.")
else:
Expand Down
Binary file added thirdparty/libespeak-ng-x64.lib
Binary file not shown.
Binary file added thirdparty/libespeak-ng-x86.lib
Binary file not shown.
Loading