mirror of
https://github.com/MLSysBook/TinyTorch.git
synced 2026-04-29 18:12:32 -05:00
36 lines
1.1 KiB
Bash
36 lines
1.1 KiB
Bash
# Python Virtual Environment Auto-Activation Template
|
|
# Copy this file as .envrc to any Python project directory
|
|
# Default usage:
|
|
# Then run: direnv allow
|
|
VENV_PATH=$(python -c "import json; print(json.load(open('.tinyrc')).get('venv_path', '.venv'))")
|
|
echo "Using virtual env in ${VENV_PATH}"
|
|
export VENV_PATH
|
|
|
|
# Check if .venv exists, create if it doesn't
|
|
if [[ ! -d "$VENV_PATH" ]]; then
|
|
echo "🔧 Creating Python virtual environment..."
|
|
python3 -m venv "$VENV_PATH"
|
|
echo "📦 Installing basic dependencies..."
|
|
source "$VENV_PATH/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_PATH/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}"
|