39 lines
989 B
Bash
39 lines
989 B
Bash
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
# Always run from this script's directory.
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
cd "$SCRIPT_DIR"
|
|
|
|
VENV_DIR=".venv"
|
|
|
|
if command -v python3 >/dev/null 2>&1; then
|
|
PYTHON_BIN="python3"
|
|
elif command -v python >/dev/null 2>&1; then
|
|
PYTHON_BIN="python"
|
|
else
|
|
echo "Error: Python was not found on PATH."
|
|
exit 1
|
|
fi
|
|
|
|
echo "Using Python: $PYTHON_BIN"
|
|
|
|
if [[ ! -x "$VENV_DIR/bin/python" ]]; then
|
|
if [[ -d "$VENV_DIR" ]]; then
|
|
echo "Existing virtual environment is not compatible with this OS. Recreating $VENV_DIR ..."
|
|
rm -rf "$VENV_DIR"
|
|
fi
|
|
echo "Creating virtual environment in $VENV_DIR ..."
|
|
"$PYTHON_BIN" -m venv "$VENV_DIR"
|
|
fi
|
|
|
|
VENV_PYTHON="$VENV_DIR/bin/python"
|
|
|
|
echo "Upgrading pip and packaging tools ..."
|
|
"$VENV_PYTHON" -m pip install --upgrade pip
|
|
|
|
echo "Installing requirements ..."
|
|
"$VENV_PYTHON" -m pip install -r requirements.txt
|
|
|
|
echo "Starting program ..."
|
|
"$VENV_PYTHON" -m src.taetigkeitsnachweis.cli |