using setup.py to install pkgs by shell script

pull/909/head
Hui Zhang 3 years ago
parent 82120c5ca4
commit e5b2c72bb6

@ -28,12 +28,15 @@ import subprocess as sp
HERE = Path(os.path.abspath(os.path.dirname(__file__)))
@contextlib.contextmanager
def pushd(new_dir):
old_dir = os.getcwd()
os.chdir(new_dir)
print(new_dir)
yield
os.chdir(old_dir)
print(old_dir)
def read(*names, **kwargs):
@ -55,17 +58,22 @@ def check_call(cmd: str, shell=False, executable=None):
raise e
def _pre_install(install_lib_dir):
def _remove(files: str):
for f in files:
f.unlink()
def _post_install(install_lib_dir):
# apt
check_call("apt-get update -y", False)
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 ', False)
'libvorbis-dev libboost-dev swig python3-dev ')
print("apt install.")
# tools/make
tool_dir = HERE / "tools"
for f in tool_dir.glob("*.done"):
f.unlink()
_remove(tool_dir.glob("*.done"))
with pushd(tool_dir):
check_call("make")
print("tools install.")
@ -73,17 +81,16 @@ def _pre_install(install_lib_dir):
# install autolog
tools_extrs_dir = HERE / 'tools/extras'
with pushd(tools_extrs_dir):
check_call(f"bash -e install_autolog.sh")
print(os.getcwd())
check_call(f"./install_autolog.sh")
print("autolog install.")
# ctcdecoder
ctcdecoder_dir = HERE/ 'deepspeech/decoders/ctcdecoder/swig'
ctcdecoder_dir = HERE / 'deepspeech/decoders/ctcdecoder/swig'
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 pushd(third_party_dir):
@ -93,15 +100,15 @@ def _post_install(install_lib_dir):
class DevelopCommand(develop):
def run(self):
self.execute(_pre_install, (self.install_lib, ), msg="Pre Install...")
develop.run(self)
# must after develop.run, or pkg install by shell will not see
self.execute(_post_install, (self.install_lib, ), msg="Post Install...")
class InstallCommand(install):
def run(self):
self.execute(_pre_install, (self.install_lib, ), msg="Pre Install...")
install.run(self)
# must after install.run, or pkg install by shell will not see
self.execute(_post_install, (self.install_lib, ), msg="Post Install...")

@ -6,15 +6,15 @@ CC ?= gcc # used for sph2pipe
# CXX = clang++ # Uncomment these lines...
# CC = clang # ...to build with Clang.
WGET ?= wget --no-check-certificate
$(WGET) ?= wget --no-check-certificate
.PHONY: all clean
all: virtualenv kenlm.done sox.done soxbindings.done mfa.done sclite.done
all: virtualenv.done kenlm.done sox.done soxbindings.done mfa.done sclite.done
virtualenv:
virtualenv.done:
test -d venv || virtualenv -p $(PYTHON) venv
touch venv/bin/activate
touch virtualenv.done
clean:
rm -fr venv
@ -26,25 +26,25 @@ kenlm.done:
# it seems that boost (1.54.0) requires higher version. After I switched to g++-5 it compiles normally.
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
test -d kenlm || $(WGET) -O - https://kheafield.com/code/kenlm.tar.gz | tar xz
rm -rf kenlm/build && mkdir -p kenlm/build && cd kenlm/build && cmake .. && make -j4 && make install
source venv/bin/activate; cd kenlm && python setup.py install
cd kenlm && python setup.py install
touch kenlm.done
sox.done:
apt install -y libvorbis-dev libmp3lame-dev libmad-ocaml-dev
test -d sox-14.4.2 || wget https://nchc.dl.sourceforge.net/project/sox/sox/14.4.2/sox-14.4.2.tar.gz --no-check-certificate
test -d sox-14.4.2 || $(WGET) https://nchc.dl.sourceforge.net/project/sox/sox/14.4.2/sox-14.4.2.tar.gz
tar -xvzf sox-14.4.2.tar.gz -C .
cd sox-14.4.2 && ./configure --prefix=/usr/ && make -j4 && make install
touch sox.done
soxbindings.done:
test -d soxbindings || git clone https://github.com/pseeth/soxbindings.git
source venv/bin/activate; cd soxbindings && python setup.py install
cd soxbindings && python setup.py install
touch soxbindings.done
mfa.done:
test -d montreal-forced-aligner || wget https://github.com/MontrealCorpusTools/Montreal-Forced-Aligner/releases/download/v1.0.1/montreal-forced-aligner_linux.tar.gz --no-check-certificate
test -d montreal-forced-aligner || $(WGET) https://github.com/MontrealCorpusTools/Montreal-Forced-Aligner/releases/download/v1.0.1/montreal-forced-aligner_linux.tar.gz
tar xvf montreal-forced-aligner_linux.tar.gz
touch mfa.done
@ -85,7 +85,7 @@ sctk-$(SCTK_GITHASH).tar.gz:
if [ -d '$(DOWNLOAD_DIR)' ]; then \
cp -p '$(DOWNLOAD_DIR)/sctk-$(SCTK_GITHASH).tar.gz' .; \
else \
$(WGET) -nv -T 10 -t 3 -O sctk-$(SCTK_GITHASH).tar.gz \
$($(WGET)) -nv -T 10 -t 3 -O sctk-$(SCTK_GITHASH).tar.gz \
https://github.com/usnistgov/SCTK/archive/$(SCTK_GITHASH).tar.gz; \
fi

@ -2,6 +2,7 @@
#install auto-log
echo "Install auto_log into default system path"
rm -rf AutoLog || true
test -d AutoLog || git clone https://github.com/LDOUBLEV/AutoLog
if [ $? != 0 ]; then
error_msg "Download auto_log failed !!!"
@ -9,8 +10,8 @@ if [ $? != 0 ]; then
fi
pushd AutoLog
pip install -r requirements.txt
python setup.py install
pip3 install -r requirements.txt
python3 setup.py install
popd
rm -rf AutoLog
rm -rf AutoLog || true

Loading…
Cancel
Save