# Python Virtual Environment Auto-Activation Template
# Copy this file as .envrc to any Python project directory
# Then run: direnv allow

# Check if .venv exists, create if it doesn't
if [[ ! -d ".venv" ]]; then
    echo "🔧 Creating Python virtual environment..."
    python3 -m venv .venv
    echo "📦 Installing basic dependencies..."
    source .venv/bin/activate
    pip install --upgrade pip
    # Uncomment the next line if you have a requirements.txt
    # pip install -r requirements.txt
fi

# Activate the virtual environment
source .venv/bin/activate

# Set common Python environment variables
export PYTHONPATH="${PWD}:${PYTHONPATH}"
export PROJECT_ROOT="${PWD}"

# Prevent Python from writing pyc files
export PYTHONDONTWRITEBYTECODE=1

# Enable Python development mode (more detailed error messages)
export PYTHONDEVMODE=1

echo "✅ TinyTorch environment activated"
echo "🐍 Python: $(python --version)"
echo "📍 Virtual env: ${VIRTUAL_ENV}"
