Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 18 additions & 17 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,40 +1,41 @@
#!/bin/bash
#!/usr/bin/env bash

folder="dabs"
venv_dir=".venv"

# Find a suitable Python 3.9+ interpreter
PYTHON_CMD=""
for cmd in python3.12 python3.11 python3.10 python3.9 python3 python; do
if command -v $cmd &> /dev/null; then
version=$($cmd -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')" 2>/dev/null)
major=$(echo $version | cut -d '.' -f 1)
minor=$(echo $version | cut -d '.' -f 2)
if [[ "$major" -ge 3 && "$minor" -ge 9 ]]; then
PYTHON_CMD=$cmd
break
fi
if command -v $cmd &>/dev/null; then
version=$($cmd -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')" 2>/dev/null)
major=$(echo "$version" | cut -d '.' -f 1)
minor=$(echo "$version" | cut -d '.' -f 2)
if [[ "$major" -ge 3 && "$minor" -ge 9 ]]; then
PYTHON_CMD=$cmd
break
fi
fi
done

if [[ -z "$PYTHON_CMD" ]]; then
echo "Python 3.9 or higher is required but not found."
echo "Please install Python 3.9+ and ensure it's in your PATH."
exit 1
echo "Python 3.9 or higher is required but not found."
echo "Please install Python 3.9+ and ensure it's in your PATH."
exit 1
fi

echo "Using Python: $PYTHON_CMD ($(${PYTHON_CMD} --version))"

# Create virtual environment if it doesn't exist
if [[ ! -d "$venv_dir" ]]; then
echo "Creating virtual environment in $venv_dir..."
$PYTHON_CMD -m venv $venv_dir
echo "Creating virtual environment in $venv_dir..."
$PYTHON_CMD -m venv $venv_dir
fi

# Activate virtual environment and install dependencies
source $venv_dir/bin/activate
# shellcheck source=/dev/null
source "$venv_dir/bin/activate"
echo "Virtual environment activated"

cd $folder
cd $folder || exit
pip install -r requirements.txt
python main.py
python main.py