1
0
Fork 0

added auto installation script

This commit is contained in:
Sangbum Kim 2018-08-24 15:36:38 +09:00
parent a8f6e77a41
commit a04853d8db
1 changed files with 33 additions and 1 deletions

View File

@ -1,3 +1,35 @@
#!/bin/bash
PATH=$VIRTUAL_ENV/bin:$PATH exec python bill_man.py $1
PYTHON_VERSION="X$(python -V 2>&1)"
if [[ "X$?" == "X0" && "X$(echo ${PYTHON_VERSION}|cut -f 2 -d ' ' |cut -f 1 -d '.')" == "X3" ]] ; then
PYTHON="$(which python)"
fi
PYTHON_VERSION="X$(python3 -V 2>&1)"
if [[ "X$?" == "X0" && "X$(echo ${PYTHON_VERSION}|cut -f 2 -d ' ' |cut -f 1 -d '.')" == "X3" ]] ; then
PYTHON="$(which python3)"
fi
if [[ "X${PYTHON}" == "X" ]] ; then
(>&2 echo "python3 not detected")
exit 1
else
(>&2 echo "detected python3 : ${PYTHON}")
fi
if [[ "X${VIRTUAL_ENV}" == "X" ]] ; then
VIRTUAL_ENV="$(pwd)/venv"
fi
if [[ ! -d "${VIRTUAL_ENV}" && ! -x "${VIRTUAL_ENV}/bin/activate" ]] ; then
(>&2 echo "virtual envioment not detected. let's installing.... in ${VIRTUAL_ENV}")
"${PYTHON}" -m venv "${VIRTUAL_ENV}"
source "${VIRTUAL_ENV}/bin/activate"
pip install -r requirements.txt
else
(>&2 echo "detected virtual environment : ${VIRTUAL_ENV}")
source "${VIRTUAL_ENV}/bin/activate"
fi
PYTHON="${VIRTUAL_ENV}/bin/python"
exec python bill_man.py $@