diff --git a/requirements.txt b/requirements.txt index db5c584b2187550f56ec03c8793ac64951c74989..2a3f06514379a351dd6a5f759601600f845a61a7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -19,12 +19,12 @@ tqdm typeguard visualdl==2.2.0 yacs -numpy +numpy==1.20.0 +numba nltk inflect librosa unidecode -numba llvmlite matplotlib pandas @@ -39,4 +39,4 @@ timer pyworld jieba phkit -yq \ No newline at end of file +yq diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000000000000000000000000000000000000..625454805b47e1f93cc675f06c55e9604a2abc65 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,9 @@ +[build_ext] +debug=0 + +[metadata] +license_file = LICENSE +description-file = README.md + +[magformat] +formatters=yapf diff --git a/setup.py b/setup.py index 4073d758a1e389b26c18f8df4fd19cf2471a040d..32575b4adc817650cb914e631c9bf47b2c397925 100644 --- a/setup.py +++ b/setup.py @@ -14,6 +14,7 @@ import io import os import re +import sys from pathlib import Path import contextlib import inspect @@ -31,10 +32,8 @@ HERE = Path(os.path.abspath(os.path.dirname(__file__))) def pushd(new_dir): old_dir = os.getcwd() os.chdir(new_dir) - try: - yield - finally: - os.chdir(old_dir) + yield + os.chdir(old_dir) def read(*names, **kwargs): @@ -43,7 +42,7 @@ def read(*names, **kwargs): return fp.read() -def check_call(cmd: str, shell=True, executable=None): +def check_call(cmd: str, shell=False, executable=None): try: sp.check_call(cmd.split(), shell=shell, @@ -53,49 +52,55 @@ def check_call(cmd: str, shell=True, executable=None): f"{__file__}:{inspect.currentframe().f_lineno}: CMD: {cmd}, Error:", e.output, file=sys.stderr) + raise e -def _pre_install(): +def _pre_install(install_lib_dir): # apt - check_call("apt-get update -y") + check_call("apt-get update -y", False) check_call("apt-get install -y " + 'vim tig tree sox pkg-config ' + 'libsndfile1 libflac-dev libogg-dev ' + - 'libvorbis-dev libboost-dev swig python3-dev ') + 'libvorbis-dev libboost-dev swig python3-dev ', False) + print("apt install.") # tools/make tool_dir = HERE / "tools" - # for f in tool_dir.glob("*.done"): - # f.unlink() + for f in tool_dir.glob("*.done"): + f.unlink() with pushd(tool_dir): check_call("make") + print("tools install.") + # install autolog + tools_extrs_dir = HERE / 'tools/extras' + with pushd(tools_extrs_dir): + check_call(f"bash -e install_autolog.sh") + print("autolog install.") -def _post_install(install_lib_dir): # ctcdecoder ctcdecoder_dir = HERE/ 'deepspeech/decoders/ctcdecoder/swig' - with puahd(ctcdecoder_dir): - check_call("setup.sh") + with pushd(ctcdecoder_dir): + check_call("bash -e setup.sh") + print("ctcdecoder install.") + +def _post_install(install_lib_dir): # install third_party third_party_dir = HERE / 'third_party' - with puahd(third_party_dir): - check_call("bash install.sh") - - # install autolog - tools_extrs_dir = HERE / 'tools/extras' - with puahd(tools_extrs_dir): - check_call("bash install_autolog.sh") + with pushd(third_party_dir): + check_call("bash -e install.sh") + print("third_party install.") class DevelopCommand(develop): def run(self): - _pre_install() + self.execute(_pre_install, (self.install_lib, ), msg="Pre Install...") develop.run(self) self.execute(_post_install, (self.install_lib, ), msg="Post Install...") class InstallCommand(install): def run(self): - _pre_install() + self.execute(_pre_install, (self.install_lib, ), msg="Pre Install...") install.run(self) self.execute(_post_install, (self.install_lib, ), msg="Post Install...") diff --git a/tools/extras/install_autolog.sh b/tools/extras/install_autolog.sh old mode 100644 new mode 100755 index 95d10bcedeb0b251fe79ec9a66d76449eef1d950..1000d7f6ac46616612a036ec13571b87e44a8f7c --- a/tools/extras/install_autolog.sh +++ b/tools/extras/install_autolog.sh @@ -1,17 +1,16 @@ #!/bin/bash #install auto-log -python -c "import auto_log" +echo "Install auto_log into default system path" +test -d AutoLog || git clone https://github.com/LDOUBLEV/AutoLog 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 \ No newline at end of file + error_msg "Download auto_log failed !!!" + exit 1 +fi + +pushd AutoLog +pip install -r requirements.txt +python setup.py install +popd + +rm -rf AutoLog