From 4c3bfce0b386c5009d0b310600e5e15786c11f5e Mon Sep 17 00:00:00 2001 From: Crooked-Krokr Date: Wed, 10 Sep 2025 19:30:02 +0100 Subject: [PATCH] Modernise setup script to use uv consistently (#2378) --- .gitignore | 1 + scripts/setup.sh | 37 +++++++++++++++++++++++++------------ 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index 673eb1d9..29db5bf7 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ build/ dist/ venv/ .venv +.venv* .mypy_cache/ .tox/ *.egg-info/ diff --git a/scripts/setup.sh b/scripts/setup.sh index 79750bdf..2957be26 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -1,28 +1,41 @@ #!/usr/bin/env bash - -# Set-up the development environment - -# Stop on errors -set -e +# Set up the development environment (respects pyproject requires-python; safe venv upgrade) +set -euo pipefail cd "$(dirname "$0")/.." +# Check if uv is installed +if ! command -v uv &>/dev/null; then + echo "❌ uv is not installed. Please install it first:" + echo " curl -LsSf https://astral.sh/uv/install.sh | sh" + echo " or visit: https://docs.astral.sh/uv/getting-started/installation/" + exit 1 +fi + env_name=${1:-".venv"} if [ -d "$env_name" ]; then echo "Virtual environment '$env_name' already exists." else echo "Creating Virtual environment..." - ${PYTHON:-python} -m venv .venv + uv venv "$env_name" fi + echo "Activating virtual environment..." -source .venv/bin/activate +source "$env_name/bin/activate" echo "Installing development dependencies..." - -pip install --upgrade pip -pip install --upgrade uv uv pip install -e "." uv pip install -e ".[test]" -uv pip install -r requirements_all.txt -pre-commit install +[[ -f requirements_all.txt ]] && uv pip install -r requirements_all.txt + + +# Install pre-commit hooks if pre-commit is available +if command -v pre-commit &>/dev/null; then + pre-commit install +else + echo "⚠️ pre-commit not available. Install with: uv pip install pre-commit" +fi + +echo "✅ Done. Interpreter: $(python -V). Package manager: $(uv --version)" +echo "To activate the virtual environment, run: source $env_name/bin/activate" -- 2.34.1