-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.envrc
More file actions
56 lines (47 loc) · 1.65 KB
/
Copy path.envrc
File metadata and controls
56 lines (47 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env bash
# Auto-activate uv virtual environment
if ! has uv; then
echo "❌ uv is not installed. Please install it first:"
echo " curl -LsSf https://astral.sh/uv/install.sh | sh"
return 1
fi
# Create virtual environment if it doesn't exist
if [[ ! -d ".venv" ]]; then
echo "📦 Creating virtual environment with uv..."
uv venv
fi
# Activate the virtual environment
if [[ -f ".venv/bin/activate" ]]; then
source .venv/bin/activate
elif [[ -f ".venv/Scripts/activate" ]]; then
source .venv/Scripts/activate
fi
# Source .envrc.local if present (for user/machine-specific settings)
if [[ -f ".envrc.local" ]]; then
echo "🔒 Sourcing .envrc.local..."
source .envrc.local
fi
# Sync dependencies (including dev dependencies)
echo "🔄 Syncing dependencies..."
uv sync --all-extras
# Install pre-commit hooks if they don't exist
if [[ -f ".pre-commit-config.yaml" ]] && [[ ! -f ".git/hooks/pre-commit" ]]; then
echo "🪝 Installing pre-commit hooks..."
uv run pre-commit install
fi
# Export environment variables
export PYTHONPATH="${PWD}/src:${PYTHONPATH}"
export UV_PROJECT_ENVIRONMENT="${PWD}/.venv"
echo "✅ Environment activated!"
echo "📁 Virtual environment: ${VIRTUAL_ENV}"
echo "🐍 Python: $(python --version)"
echo "📦 uv: $(uv --version)"
# Show available commands
echo ""
echo "🚀 Available commands:"
echo " task lint # Lint (with auto-fix)"
echo " task format # Format code"
echo " task type # Type check"
echo " task test # Run tests"
echo " task cov # Run tests with coverage"
echo " task check # lint + type + test"