mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add piper to binary macOS builds
This commit is contained in:
parent
e5b6603b45
commit
95854ebc16
@ -15,7 +15,8 @@ from functools import partial
|
|||||||
from bypy.constants import LIBDIR, OUTPUT_DIR, PREFIX, python_major_minor_version
|
from bypy.constants import LIBDIR, OUTPUT_DIR, PREFIX, python_major_minor_version
|
||||||
from bypy.constants import SRC as CALIBRE_DIR
|
from bypy.constants import SRC as CALIBRE_DIR
|
||||||
from bypy.freeze import extract_extension_modules, fix_pycryptodome, freeze_python, is_package_dir, path_to_freeze_dir
|
from bypy.freeze import extract_extension_modules, fix_pycryptodome, freeze_python, is_package_dir, path_to_freeze_dir
|
||||||
from bypy.utils import copy_binaries, create_job, get_dll_path, mkdtemp, parallel_build, py_compile, run, walk
|
from bypy.pkgs.piper import copy_piper_dir
|
||||||
|
from bypy.utils import create_job, get_dll_path, mkdtemp, parallel_build, py_compile, run, walk
|
||||||
|
|
||||||
j = os.path.join
|
j = os.path.join
|
||||||
self_dir = os.path.dirname(os.path.abspath(__file__))
|
self_dir = os.path.dirname(os.path.abspath(__file__))
|
||||||
@ -109,11 +110,7 @@ def import_site_packages(srcdir, dest):
|
|||||||
|
|
||||||
def copy_piper(env):
|
def copy_piper(env):
|
||||||
print('Copying piper...')
|
print('Copying piper...')
|
||||||
src = os.path.join(PREFIX, 'piper')
|
copy_piper_dir(PREFIX, env.bin_dir)
|
||||||
dest = os.path.join(env.bin_dir, 'piper')
|
|
||||||
copy_binaries(os.path.join(src, 'lib*'), dest)
|
|
||||||
copy_binaries(os.path.join(src, 'piper*'), dest)
|
|
||||||
shutil.copytree(os.path.join(src, 'espeak-ng-data'), os.path.join(dest, 'espeak-ng-data'))
|
|
||||||
|
|
||||||
|
|
||||||
def copy_libs(env):
|
def copy_libs(env):
|
||||||
|
@ -22,6 +22,7 @@ from itertools import repeat
|
|||||||
from bypy.constants import OUTPUT_DIR, PREFIX, PYTHON, python_major_minor_version
|
from bypy.constants import OUTPUT_DIR, PREFIX, PYTHON, python_major_minor_version
|
||||||
from bypy.constants import SRC as CALIBRE_DIR
|
from bypy.constants import SRC as CALIBRE_DIR
|
||||||
from bypy.freeze import extract_extension_modules, fix_pycryptodome, freeze_python, is_package_dir, path_to_freeze_dir
|
from bypy.freeze import extract_extension_modules, fix_pycryptodome, freeze_python, is_package_dir, path_to_freeze_dir
|
||||||
|
from bypy.pkgs.piper import copy_piper_dir
|
||||||
from bypy.utils import current_dir, get_arches_in_binary, mkdtemp, py_compile, timeit, walk
|
from bypy.utils import current_dir, get_arches_in_binary, mkdtemp, py_compile, timeit, walk
|
||||||
|
|
||||||
abspath, join, basename, dirname = os.path.abspath, os.path.join, os.path.basename, os.path.dirname
|
abspath, join, basename, dirname = os.path.abspath, os.path.join, os.path.basename, os.path.dirname
|
||||||
@ -527,6 +528,15 @@ class Freeze:
|
|||||||
|
|
||||||
@flush
|
@flush
|
||||||
def add_misc_libraries(self):
|
def add_misc_libraries(self):
|
||||||
|
|
||||||
|
def add_lib(src):
|
||||||
|
x = os.path.basename(src)
|
||||||
|
print('\nAdding', x)
|
||||||
|
shutil.copy2(src, self.frameworks_dir)
|
||||||
|
dest = join(self.frameworks_dir, x)
|
||||||
|
self.set_id(dest, self.FID + '/' + x)
|
||||||
|
self.fix_dependencies_in_lib(dest)
|
||||||
|
|
||||||
for x in (
|
for x in (
|
||||||
'usb-1.0.0', 'mtp.9', 'chm.0', 'sqlite3.0', 'hunspell-1.7.0',
|
'usb-1.0.0', 'mtp.9', 'chm.0', 'sqlite3.0', 'hunspell-1.7.0',
|
||||||
'icudata.73', 'icui18n.73', 'icuio.73', 'icuuc.73', 'hyphen.0', 'uchardet.0',
|
'icudata.73', 'icui18n.73', 'icuio.73', 'icuuc.73', 'hyphen.0', 'uchardet.0',
|
||||||
@ -534,13 +544,9 @@ class Freeze:
|
|||||||
'brotlicommon.1', 'brotlidec.1', 'brotlienc.1', 'zstd.1', 'jbig.2.1', 'tiff.6',
|
'brotlicommon.1', 'brotlidec.1', 'brotlienc.1', 'zstd.1', 'jbig.2.1', 'tiff.6',
|
||||||
'crypto.3', 'ssl.3', 'iconv.2', # 'ltdl.7'
|
'crypto.3', 'ssl.3', 'iconv.2', # 'ltdl.7'
|
||||||
):
|
):
|
||||||
print('\nAdding', x)
|
|
||||||
x = 'lib%s.dylib' % x
|
x = 'lib%s.dylib' % x
|
||||||
src = join(PREFIX, 'lib', x)
|
src = join(PREFIX, 'lib', x)
|
||||||
shutil.copy2(src, self.frameworks_dir)
|
add_lib(src)
|
||||||
dest = join(self.frameworks_dir, x)
|
|
||||||
self.set_id(dest, self.FID + '/' + x)
|
|
||||||
self.fix_dependencies_in_lib(dest)
|
|
||||||
|
|
||||||
# OpenSSL modules and engines
|
# OpenSSL modules and engines
|
||||||
for x in ('ossl-modules', 'engines-3'):
|
for x in ('ossl-modules', 'engines-3'):
|
||||||
@ -551,6 +557,8 @@ class Freeze:
|
|||||||
dylib = join(dest, dylib)
|
dylib = join(dest, dylib)
|
||||||
self.set_id(dylib, self.FID + '/' + x + '/' + os.path.basename(dylib))
|
self.set_id(dylib, self.FID + '/' + x + '/' + os.path.basename(dylib))
|
||||||
self.fix_dependencies_in_lib(dylib)
|
self.fix_dependencies_in_lib(dylib)
|
||||||
|
# Piper TTS
|
||||||
|
copy_piper_dir(PREFIX, self.frameworks_dir)
|
||||||
|
|
||||||
@flush
|
@flush
|
||||||
def add_site_packages(self):
|
def add_site_packages(self):
|
||||||
|
@ -511,6 +511,8 @@ def bundled_binaries_dir() -> str:
|
|||||||
def piper_cmdline() -> tuple[str, ...]:
|
def piper_cmdline() -> tuple[str, ...]:
|
||||||
ext = '.exe' if iswindows else ''
|
ext = '.exe' if iswindows else ''
|
||||||
if bbd := bundled_binaries_dir():
|
if bbd := bundled_binaries_dir():
|
||||||
|
if ismacos:
|
||||||
|
return (os.path.join(sys.frameworks_dir, 'piper', 'piper'),)
|
||||||
return (os.path.join(bbd, 'piper', 'piper' + ext),)
|
return (os.path.join(bbd, 'piper', 'piper' + ext),)
|
||||||
if pd := os.environ.get('PIPER_TTS_DIR'):
|
if pd := os.environ.get('PIPER_TTS_DIR'):
|
||||||
return (os.path.join(pd, 'piper' + ext),)
|
return (os.path.join(pd, 'piper' + ext),)
|
||||||
|
@ -123,7 +123,7 @@ class BuildTest(unittest.TestCase):
|
|||||||
from speechd.client import SSIPClient
|
from speechd.client import SSIPClient
|
||||||
del SSIPClient
|
del SSIPClient
|
||||||
|
|
||||||
@unittest.skipUnless(islinux, 'Piper only used on Linux')
|
@unittest.skipIf(iswindows, 'Piper not available on windows')
|
||||||
def test_piper(self):
|
def test_piper(self):
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user