1
0
Fork 0
bill_man/bill_man

36 lines
1.0 KiB
Bash
Executable File

#!/bin/bash
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 $@