2022-06-24 20:19:51 +00:00
|
|
|
#!/usr/bin/env bash
|
2022-06-24 20:11:21 +00:00
|
|
|
|
|
|
|
if [ ! -d "tnc" ]; then
|
|
|
|
echo "Error: Run this script from the main FreeDATA directory."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Common variables
|
2022-06-24 20:19:51 +00:00
|
|
|
VENVDIR="$(pwd)/.venv"
|
2022-06-24 20:11:21 +00:00
|
|
|
|
|
|
|
# Choose an appropriate python interpreter
|
|
|
|
CHOSEN=/bin/python3
|
|
|
|
for i in python3.8 python3.9 python3.10 python3.7
|
|
|
|
do
|
|
|
|
if [ -x /bin/$i ]; then
|
|
|
|
CHOSEN="/bin/$i"
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
# Verify it's there.
|
|
|
|
if [ ! -x ${CHOSEN} ]; then
|
|
|
|
echo "Error: ${CHOSEN} is not executable or does not exist."
|
2022-06-25 19:43:30 +00:00
|
|
|
echo "Note: FreeDATA requires Python 3 (higher than version 3.6)."
|
2022-06-24 20:11:21 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Clear the existing virtual environment.
|
|
|
|
if [ -e "${VENVDIR}" ]; then
|
|
|
|
${CHOSEN} -m venv "${VENVDIR}" --clear
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Create the virtual environment
|
|
|
|
${CHOSEN} -m venv "${VENVDIR}"
|
|
|
|
|
|
|
|
# Activate the virtual environment, if needed
|
2022-06-24 20:17:44 +00:00
|
|
|
if [ -z "${VIRTUAL_ENV}" ] || [ "${VIRTUAL_ENV}" != "${VENVDIR}" ]; then
|
2022-06-24 20:11:21 +00:00
|
|
|
source "${VENVDIR}/activate"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Cease using ${CHOSEN} as the interpreter we want now is in our path.
|
|
|
|
|
|
|
|
# Install packages
|
|
|
|
python3 -m pip install -U pip wheel
|
|
|
|
python3 -m pip install -r requirements.txt
|
|
|
|
|
|
|
|
echo ""
|
|
|
|
echo "Be sure to run '. $VENVDIR/activate' before starting the daemon."
|