Description
pyenv-virtualenv keeps track of all virtual environments created using pyenv virtualenv, but does not track where those environments are used (i.e., which directories contain .python-version files referencing them).
This feature would improve environment management by logging usage context and allowing users to query where virtualenvs are active.
Problem
- No way to map virtualenvs to the directories that use them
- Makes it hard to clean up, audit, or understand which projects rely on which environments
- Users have to manually
grep for .python-version files to infer usage
Proposed Feature
Introduce optional usage tracking for virtualenvs:
- When a virtualenv is activated (via
pyenv activate, or a .python-version triggers it), log an entry with:
- Timestamp
- Virtualenv name
- Path to the directory where it was used
Provide a new CLI command:
pyenv virtualenv usage — List all usage across virtualenvs
pyenv virtualenv usage <env-name> — Show where a specific env is used
Logging should be opt-in via an environment variable or config, such as:
export PYENV_VIRTUALENV_LOG_USAGE=1
Description
pyenv-virtualenvkeeps track of all virtual environments created usingpyenv virtualenv, but does not track where those environments are used (i.e., which directories contain.python-versionfiles referencing them).This feature would improve environment management by logging usage context and allowing users to query where virtualenvs are active.
Problem
grepfor.python-versionfiles to infer usageProposed Feature
Introduce optional usage tracking for virtualenvs:
pyenv activate, or a.python-versiontriggers it), log an entry with:Provide a new CLI command:
pyenv virtualenv usage— List all usage across virtualenvspyenv virtualenv usage <env-name>— Show where a specific env is usedLogging should be opt-in via an environment variable or config, such as:
export PYENV_VIRTUALENV_LOG_USAGE=1