How pyenv/pyenv-virtualenv works
Main Components
a) Core Components:
• pyenv (parent system)
• pyenv-virtualenv plugin
• Virtual Environment Management System
• Environment Handlers (virtualenv, venv, conda)
b) Integration Points:
• Shell Integration
• pyenv Hooks System
• Environment Activation/Deactivation System
User Shell Environment
• ↕
• pyenv-virtualenv
• ↕
• pyenv core
• ↕
Virtual Environment Backends
Component Details
a) Command Interface Layer:
• Bin/ directory commands (activate, deactivate, virtualenv, etc.)
• To the shell integration system
b) Core Processing Layer:
• Libexec/ directory components
• Etc/pyenv.d/ hooks system
• Demonstrate how the plugin integrates with pyenv
c) Backend Integration Layer:
• Three parallel paths for different virtual environment types:
• virtualenv
• venv (Python 3.3+)
• conda environments
Data Flow Indicators
• Command flow from shell to plugin
• Plugin interactions with pyenv
• Virtual environment creation/management flow
• Activation/deactivation state changes
Implementation Details
• Hook system implementation (etc/pyenv.d/)
• Test infrastructure (test/ directory)
• Shell integration points (sh-activate, sh-deactivate)
Specific Elements
┌─ Shell Environment ─────────────────┐
• (bash/zsh/fish integration) │
• ┬────────────────────┘
• ↓
┌─ Command Interface ────────────────┐
• pyenv virtualenv │
• pyenv activate/deactivate │
• pyenv virtualenvs │
• ┬──────────────────┘
• ↓
┌─ Core Plugin Logic ───────────────┐
• Environment Management │
• Hook System │
• Auto-activation │
• ┬──────────────────┘
• ↓
┌─ Backend Handlers ────────────────┐
• ┌─────────┐ ┌───────┐ ┌────────┐ │
• virtualenv│ │ venv │ │ conda │ │
• ┘ └───────┘ └────────┘ │
• ┘
Additional Notes
• Clear boundaries between pyenv core and plugin functionality
• Auto-activation feature as it's a key differentiator
• Configuration points for environment variables