auto-uv-env ๐
Automatic UV-based Python virtual environment management for your shell.
auto-uv-env watches directory changes, discovers the nearest pyproject.toml, creates a project-local virtual environment with uv, and activates/deactivates it automatically.
Why auto-uv-env?
- ๐ Automatic activation when entering Python projects
- ๐ UV-powered environment creation and Python installation
- ๐ฆ
pyproject.tomlaware (requires-python) - ๐ง Parent-directory project discovery (works from subdirectories)
- ๐งน Clean deactivation when leaving managed project trees
- ๐ก๏ธ Manual venv protection (does not override manually activated environments)
- โก Optimized for low overhead in non-project directories
Quick Start
1. Install auto-uv-env
Quick install (any system):
curl -LsSf https://auto-uv-env.ashwch.com/install.sh | sh
macOS with Homebrew (recommended for Mac):
brew tap ashwch/tap
brew install auto-uv-env
2. Add to your shell
Zsh (~/.zshrc):
source $(brew --prefix)/share/auto-uv-env/auto-uv-env.zsh
Bash (~/.bashrc):
source $(brew --prefix)/share/auto-uv-env/auto-uv-env.bash
Fish (~/.config/fish/config.fish):
source (brew --prefix)/share/auto-uv-env/auto-uv-env.fish
3. Start using it!
cd my-python-project/src/app
# ๐ Setting up Python 3.11 with UV...
# โ
Virtual environment created
# ๐ UV environment activated (Python 3.11.x)
How It Works
- Walk upward from
$PWDto find the nearestpyproject.toml. - If
.auto-uv-env-ignoreappears first, activation is skipped for that subtree. - Read
requires-pythonfrom the discovered project root. - Create
<project-root>/.venvwhen missing. - Activate on entry and deactivate only environments managed by auto-uv-env.
- If a manual venv is active, auto-uv-env does not override it.
Features
โก Performance and Reliability
- v1.0.7 delivered roughly 93% startup overhead improvement.
- Typical startup overhead is low in Python projects and effectively near-zero in non-project directories.
- Directory-change overhead is typically sub-millisecond.
- Command path caching and lazy loading keep common shell paths fast.
๐ฏ Intelligent Activation
- Project-aware parent discovery from subdirectories
requires-pythonversion matching frompyproject.toml- Ignore-file precedence with
.auto-uv-env-ignore - Manual venv protection to avoid breaking user-managed workflows
๐ก๏ธ Security First
- Path validation blocks traversal-style venv names
- Safe directive parsing in shell adapters
- Security checks in CI and local quality gates
Documentation
- Installation:
/installation/ - Usage and troubleshooting:
/usage/ - Contributor guide:
/contributing/ - Deciding between tools:
/alternatives/ - Repo contributor entrypoint: CONTRIBUTE.md
- Release runbook: RELEASE.md
Requirements
- UV - Install with:
curl -LsSf https://astral.sh/uv/install.sh | sh - A shell (Zsh, Bash, or Fish)
- Python projects with
pyproject.toml