Modernise setup script to use uv consistently (#2378)
authorCrooked-Krokr <paulandrewcrooks@gmail.com>
Wed, 10 Sep 2025 18:30:02 +0000 (19:30 +0100)
committerGitHub <noreply@github.com>
Wed, 10 Sep 2025 18:30:02 +0000 (20:30 +0200)
.gitignore
scripts/setup.sh

index 673eb1d99cdc189b52e5dd980bf2c9a963137ae8..29db5bf73bfd6582e1b00e276adbfe547448f76c 100644 (file)
@@ -10,6 +10,7 @@ build/
 dist/
 venv/
 .venv
+.venv*
 .mypy_cache/
 .tox/
 *.egg-info/
index 79750bdf8dcda7166ad9c4c7eaaa51678b059568..2957be261602b7a0b645caa1d0535489b13cae59 100755 (executable)
@@ -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"