#!/bin/sh
# Set up python dependencies using either uv or pip-tools

# Check if a Python virtual environment is active
if [ -z "${VIRTUAL_ENV}" ]; then
	echo "ERROR: No active Python virtual environment detected."
	echo "Please activate a virtual environment and run this script again."
	exit 1
fi

# Check if uv is installed
if command -v uv >/dev/null 2>&1; then
	echo "Setting up dependencies using uv."
	uv pip compile requirements.in -o requirements.txt
	uv pip sync requirements.txt
# Check if pip-tools is installed
elif command -v pip-compile >/dev/null 2>&1; then
	echo "uv is not installed. Falling back to pip-tools."
	pip-compile requirements.in -o requirements.txt
	pip-sync
else
	echo "Neither uv nor pip-tools are installed. Please install either uv or pip-tools and run this script again."
	exit 1
fi
