pull/909/head
Hui Zhang 3 years ago
parent ba28c92b41
commit 86df36a158

@ -39,4 +39,4 @@ timer
pyworld
jieba
phkit
yq
yq

@ -14,6 +14,9 @@
import io
import os
import re
from pathlib import Path
import contextlib
import inspect
from setuptools import find_packages
from setuptools import setup
@ -22,7 +25,7 @@ from setuptools.command.develop import develop
from setuptools.command.install import install
import subprocess as sp
HERE = os.path.abspath(os.path.dirname(__file__))
HERE = Path(os.path.abspath(os.path.dirname(__file__)))
def read(*names, **kwargs):
@ -36,16 +39,52 @@ long_description = read("README.md")
deps = [d.strip() for d in read('requirements.txt').split()]
@contextlib.contextmanager
def pushd(new_dir):
old_dir = os.getcwd()
os.chdir(new_dir)
try:
yield
finally:
os.chdir(old_dir)
def check_call(cmd: str, shell=False, executable=None):
try:
sp.check_call(cmd.split(),
shell=shell,
executable="/bin/bash" if shell else executable)
except sp.CalledProcessError as e:
print(
f"{__file__}:{inspect.currentframe().f_lineno}: CMD: {cmd}, Error:",
e.output,
file=sys.stderr)
def _pre_install():
sp.check_call("apt-get update -y".split())
sp.check_call("apt-get install -y".split() +
'vim tig tree sox pkg-config'.split() +
'libsndfile1 libflac-dev libogg-dev'.split() +
'libvorbis-dev libboost-dev swig python3-dev'.split())
# apt
check_call("apt-get update -y")
check_call("apt-get install -y " + 'vim tig tree sox pkg-config ' +
'libsndfile1 libflac-dev libogg-dev ' +
'libvorbis-dev libboost-dev swig python3-dev ')
# tools/make
tool_dir = HERE / "tools"
for f in tool_dir.glob("*.done"):
f.unlink()
with pushd(tool_dir):
check_call("make", True)
def _post_install(install_lib_dir):
pass
# ctcdecoder
check_call(
"pushd deepspeech/decoders/ctcdecoder/swig && bash setup.sh && popd")
# install third_party
check_call("pushd third_party && bash install.sh && popd")
# install autolog
check_call("pushd tools/extras && bash install_autolog.sh && popd")
class DevelopCommand(develop):
@ -76,7 +115,7 @@ class UploadCommand(Command):
def run(self):
try:
print("Removing previous dist/ ...")
shutil.rmtree(os.path.join(HERE, "dist"))
shutil.rmtree(str(HERE / "dist"))
except OSError:
pass
print("Building source distribution...")

@ -24,7 +24,7 @@ clean:
kenlm.done:
# Ubuntu 16.04 透過 apt 會安裝 boost 1.58.0
# it seems that boost (1.54.0) requires higher version. After I switched to g++-5 it compiles normally.
apt install -y build-essential cmake libboost-system-dev libboost-thread-dev libboost-program-options-dev libboost-test-dev libeigen3-dev zlib1g-dev libbz2-dev liblzma-dev
apt install -y --allow-unauthenticated build-essential cmake libboost-system-dev libboost-thread-dev libboost-program-options-dev libboost-test-dev libeigen3-dev zlib1g-dev libbz2-dev liblzma-dev
apt-get install -y gcc-5 g++-5 && update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 50 && update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-5 50
test -d kenlm || wget -O - https://kheafield.com/code/kenlm.tar.gz --no-check-certificate | tar xz
rm -rf kenlm/build && mkdir -p kenlm/build && cd kenlm/build && cmake .. && make -j4 && make install

@ -0,0 +1,17 @@
#!/bin/bash
#install auto-log
python -c "import auto_log"
if [ $? != 0 ]; then
info_msg "Install auto_log into default system path"
test -d AutoLog || git clone https://github.com/LDOUBLEV/AutoLog
if [ $? != 0 ]; then
error_msg "Download auto_log failed !!!"
exit 1
fi
cd AutoLog
pip install -r requirements.txt
python setup.py install
cd ..
rm -rf AutoLog
fi
Loading…
Cancel
Save