#!/usr/bin/env sh
cd "$(dirname "$0")" || exit 1
echo "Starting LIVA CORE Trial..."

if ! command -v python3 >/dev/null 2>&1; then
  echo "Python 3 was not found. Please install Python 3.10 or newer."
  exit 1
fi

if [ ! -x ".venv/bin/python" ]; then
  echo "Creating local Python environment..."
  python3 -m venv .venv
fi

echo "Installing/updating required packages..."
".venv/bin/python" -m pip install --upgrade pip
".venv/bin/python" -m pip install -r requirements.txt

echo "Opening LIVA CORE Trial at http://localhost:8501"
".venv/bin/python" -m streamlit run app.py --server.port 8501 --server.headless true --server.fileWatcherType none --browser.gatherUsageStats false
