From 7d02580a2bb359ea1c793c658dbbe857cf0a5a0b Mon Sep 17 00:00:00 2001 From: Matthias Date: Wed, 7 Aug 2019 21:03:03 +0200 Subject: [PATCH 1/5] setup.sh script shall fail if venv initialization fails --- setup.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/setup.sh b/setup.sh index fe7110ef6..908e77767 100755 --- a/setup.sh +++ b/setup.sh @@ -39,15 +39,13 @@ function updateenv() { echo "-------------------------" source .env/bin/activate echo "pip install in-progress. Please wait..." - # Install numpy first to have py_find_1st install clean - ${PYTHON} -m pip install --upgrade pip numpy - ${PYTHON} -m pip install --upgrade -r requirements.txt - + ${PYTHON} -m pip install --upgrade pip read -p "Do you want to install dependencies for dev [y/N]? " if [[ $REPLY =~ ^[Yy]$ ]] then ${PYTHON} -m pip install --upgrade -r requirements-dev.txt else + ${PYTHON} -m pip install --upgrade -r requirements.txt echo "Dev dependencies ignored." fi @@ -90,7 +88,7 @@ function install_macos() { # Install bot Debian_ubuntu function install_debian() { sudo apt-get update - sudo apt-get install build-essential autoconf libtool pkg-config make wget git + sudo apt-get install -y build-essential autoconf libtool pkg-config make wget git install_talib } @@ -129,6 +127,10 @@ function reset() { echo ${PYTHON} -m venv .env + if [ $? -ne 0 ]; then + echo "Could not create virtual environment. Leaving now" + exit 1 + fi updateenv } From cc4900f66cc8cc6298fe6b3dde250ed67e783b0f Mon Sep 17 00:00:00 2001 From: Matthias Date: Wed, 7 Aug 2019 21:19:16 +0200 Subject: [PATCH 2/5] Doublecheck if virtualenv IS present --- setup.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/setup.sh b/setup.sh index 908e77767..2ca6e4460 100755 --- a/setup.sh +++ b/setup.sh @@ -37,6 +37,10 @@ function updateenv() { echo "-------------------------" echo "Updating your virtual env" echo "-------------------------" + if [ ! -f .env/bin/activate ]; then + echo "Something went wrong, no virtual environment found." + exit 1 + fi source .env/bin/activate echo "pip install in-progress. Please wait..." ${PYTHON} -m pip install --upgrade pip From 757538f1147a605f1f246821abdbfee0ac50bb9b Mon Sep 17 00:00:00 2001 From: Matthias Date: Wed, 7 Aug 2019 21:35:52 +0200 Subject: [PATCH 3/5] Run ldconfig to add /usr/local/lib to path --- setup.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/setup.sh b/setup.sh index 2ca6e4460..9bdafec0d 100755 --- a/setup.sh +++ b/setup.sh @@ -72,6 +72,10 @@ function install_talib() { ./configure --prefix=/usr/local make sudo make install + if [ -x "$(command -v apt-get)" ]; then + echo "Updating library path using ldconfig" + sudo ldconfig + fi cd .. && rm -rf ./ta-lib/ cd .. } From 831e708897edf62f2950f97aa67d1ac89b2cdfdb Mon Sep 17 00:00:00 2001 From: Matthias Date: Wed, 7 Aug 2019 21:44:47 +0200 Subject: [PATCH 4/5] Detect virtualenv and quit in that case --- setup.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/setup.sh b/setup.sh index 9bdafec0d..d936e20f1 100755 --- a/setup.sh +++ b/setup.sh @@ -11,6 +11,12 @@ function check_installed_pip() { # Check which python version is installed function check_installed_python() { + if [ -n "${VIRTUAL_ENV}" ]; then + echo "Please deactivate your virtual environment before running setup.sh." + echo "You can do this by running 'deactivate'." + exit 2 + fi + which python3.7 if [ $? -eq 0 ]; then echo "using Python 3.7" From 7a47d81b7b75f42480bf8af7b4e2f440ae6fe67a Mon Sep 17 00:00:00 2001 From: Matthias Date: Wed, 7 Aug 2019 21:45:58 +0200 Subject: [PATCH 5/5] Ensure git reset --hard is realy desired --- setup.sh | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/setup.sh b/setup.sh index d936e20f1..c4b6e074a 100755 --- a/setup.sh +++ b/setup.sh @@ -117,28 +117,33 @@ function reset() { echo "----------------------------" echo "Reseting branch and virtual env" echo "----------------------------" + if [ "1" == $(git branch -vv |grep -cE "\* develop|\* master") ] then - if [ -d ".env" ]; then - echo "- Delete your previous virtual env" - rm -rf .env - fi - git fetch -a + read -p "Reset git branch? (This will remove all changes you made!) [y/N]? " + if [[ $REPLY =~ ^[Yy]$ ]]; then - if [ "1" == $(git branch -vv |grep -c "* develop") ] - then - echo "- Hard resetting of 'develop' branch." - git reset --hard origin/develop - elif [ "1" == $(git branch -vv |grep -c "* master") ] - then - echo "- Hard resetting of 'master' branch." - git reset --hard origin/master + git fetch -a + + if [ "1" == $(git branch -vv |grep -c "* develop") ] + then + echo "- Hard resetting of 'develop' branch." + git reset --hard origin/develop + elif [ "1" == $(git branch -vv |grep -c "* master") ] + then + echo "- Hard resetting of 'master' branch." + git reset --hard origin/master + fi fi else echo "Reset ignored because you are not on 'master' or 'develop'." fi + if [ -d ".env" ]; then + echo "- Delete your previous virtual env" + rm -rf .env + fi echo ${PYTHON} -m venv .env if [ $? -ne 0 ]; then