From 7114cc29ab734dd8a0578eadb51bf3f6cf2220b2 Mon Sep 17 00:00:00 2001 From: Greg Hogan Date: Wed, 21 Oct 2020 11:36:18 -0700 Subject: [PATCH] improve update_requirements.sh --- update_requirements.sh | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/update_requirements.sh b/update_requirements.sh index 4fb40cc49..d716cda4b 100755 --- a/update_requirements.sh +++ b/update_requirements.sh @@ -1,6 +1,30 @@ #!/bin/bash -e -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" +cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null -cd "$DIR" -sudo -- bash -c "source /etc/profile.d/comma_dev.sh; pip install pip==20.1.1 pipenv==2020.8.13; pipenv install --dev --deploy --system" +if ! command -v pyenv &> /dev/null; then + echo "please install pyenv ..." + echo "https://github.com/pyenv/pyenv-installer" + echo "example:" + echo "curl https://pyenv.run | bash" + echo "echo 'export PYENV_ROOT=\"\$HOME/.pyenv\"' >> ~/.bashrc" + echo "echo 'export PATH=\"\$PYENV_ROOT/bin:\$PYENV_ROOT/shims:\$PATH\"' >> ~/.bashrc" + echo "exec \"\$SHELL\"" + exit 1 +fi + +export MAKEFLAGS="-j$(nproc)" + +PYENV_PYTHON_VERSION=$(cat .python-version) +if ! pyenv prefix ${PYENV_PYTHON_VERSION} &> /dev/null; then + echo "pyenv ${PYENV_PYTHON_VERSION} install ..." + CONFIGURE_OPTS=--enable-shared pyenv install -f ${PYENV_PYTHON_VERSION} +fi + +if ! command -v pipenv &> /dev/null; then + echo "pipenv install ..." + pip install pipenv +fi + +echo "pip packages install ..." +pipenv install --dev --deploy --system