From 0ca468cd19efc2fe8eb742c69d43f549061f97d7 Mon Sep 17 00:00:00 2001 From: Hui Zhang Date: Tue, 23 Mar 2021 09:25:15 +0000 Subject: [PATCH] fix install --- README.md | 1 + README_cn.md | 1 + setup.sh | 22 ++++++++++++++++------ utils/log.sh | 11 +++++++++++ 4 files changed, 29 insertions(+), 6 deletions(-) create mode 100644 utils/log.sh diff --git a/README.md b/README.md index c2fa98189..9c46683a7 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,7 @@ * python>=3.7 * paddlepaddle>=2.0.0 +* Ubuntu - Run the setup script for the remaining dependencies diff --git a/README_cn.md b/README_cn.md index 05cd0e818..65891190b 100644 --- a/README_cn.md +++ b/README_cn.md @@ -16,6 +16,7 @@ ## 安装 * python>=3.7 * paddlepaddle>=2.0.0 +* Ubuntu - 安装依赖 diff --git a/setup.sh b/setup.sh index e2c38af77..d0f37f900 100644 --- a/setup.sh +++ b/setup.sh @@ -1,12 +1,18 @@ #! /usr/bin/env bash +source utils/log.sh + + SUDO='sudo' if [ $(id -u) -eq 0 ]; then SUDO='' fi -if [ -e /etc/lsb-release ];then +if [ -e /etc/lsb-release ]; then ${SUDO} apt-get install -y pkg-config libflac-dev libogg-dev libvorbis-dev libboost-dev swig python3-dev +else + error_msg "Please using Ubuntu or install `pkg-config libflac-dev libogg-dev libvorbis-dev libboost-dev swig python3-dev` by user." + exit -1 fi # install python dependencies @@ -14,17 +20,17 @@ if [ -f "requirements.txt" ]; then pip3 install -r requirements.txt fi if [ $? != 0 ]; then - echo "Install python dependencies failed !!!" + error_msg "Install python dependencies failed !!!" exit 1 fi # install package libsndfile python3 -c "import soundfile" if [ $? != 0 ]; then - echo "Install package libsndfile into default system path." + info_msg "Install package libsndfile into default system path." wget "http://www.mega-nerd.com/libsndfile/files/libsndfile-1.0.28.tar.gz" if [ $? != 0 ]; then - echo "Download libsndfile-1.0.28.tar.gz failed !!!" + error_msg "Download libsndfile-1.0.28.tar.gz failed !!!" exit 1 fi tar -zxvf libsndfile-1.0.28.tar.gz @@ -42,6 +48,10 @@ if [ $? != 0 ]; then sh setup.sh cd - > /dev/null fi +python3 -c "import pkg_resources; pkg_resources.require(\"swig_decoders==1.1\")" +if [ $? != 0 ]; then + error_msg "Please check why decoder install error!" + exit -1 +fi - -echo "Install all dependencies successfully." +info_msg "Install all dependencies successfully." diff --git a/utils/log.sh b/utils/log.sh new file mode 100644 index 000000000..84591b076 --- /dev/null +++ b/utils/log.sh @@ -0,0 +1,11 @@ +_HDR_FMT="%.23s %s[%s]: " +_ERR_MSG_FMT="ERROR: ${_HDR_FMT}%s\n" +_INFO_MSG_FMT="INFO: ${_HDR_FMT}%s\n" + +error_msg() { + printf "$_ERR_MSG_FMT" $(date +%F.%T.%N) ${BASH_SOURCE[1]##*/} ${BASH_LINENO[0]} "${@}" +} + +info_msg() { + printf "$_INFO_MSG_FMT" $(date +%F.%T.%N) ${BASH_SOURCE[1]##*/} ${BASH_LINENO[0]} "${@}" +}