Document the virtualenv, activate and deactivate hooks

Abierto Apto para principiantes
#552 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@officialasishkumar ya está trabajando en esto.

Desde el 4/12/2026.

  • #553 de @officialasishkumar — abierto

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
82/100
Tipo de issue
Documentación
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
bash, fish, shell, zsh

Línea de trabajo

Empieza por la documentación existente del hook virtualenv-delete en el README y luego lee el código de registro y ejecución de los hooks para virtualenv, activate y deactivate, para confirmar los nombres de los hooks, las variables y el comportamiento de la shell descritos en la issue. Añade una sección Hooks con esos detalles, un ejemplo de activate/deactivate en Bash, Zsh y Fish, y un enlace a la documentación existente de virtualenv-delete. El trabajo estará terminado cuando los puntos de los hooks documentados y el ejemplo coincidan con el comportamiento descrito en la issue.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Describe the intended use case

  • Writing a hook script for pyenv-virtualenv, e.g. a plugin like pyenv-jupyter-kernel that reacts to pyenv virtualenv, or a user script in $(pyenv root)/pyenv.d/activate/ that sets an environment variable whenever a virtualenv is activated (#428, #514).
  • pyenv virtualenv, pyenv activate and pyenv deactivate support hooks (before_virtualenv/after_virtualenv, before_activate/after_activate, before_deactivate/after_deactivate), but the README doesn't mention them. Only the virtualenv-delete hooks are documented. The "Reset existing virtualenv" section even says "virtualenv-delete and virtualenv Pyenv hooks are run", but virtualenv hooks aren't explained anywhere.
  • The Pyenv wiki's Authoring plugins page explains the general mechanism, but not which hook points pyenv-virtualenv has. In #514 the advice was to read pyenv-sh-activate's source to see where hook code runs.
  • Things you currently can only learn from the source:
    • the registration functions and the variables hook code can read (VERSION_NAME, VIRTUALENV_NAME, VIRTUALENV_PATH, STATUS for virtualenv; venv, prefix, shell for activate/deactivate);
    • that the stdout of activate/deactivate hooks is evaluated by the user's shell, so a hook changes the shell environment by printing code in the syntax of $shell;
    • that activation first deactivates the current virtualenv, so the deactivate hooks run on activation too, with empty venv/prefix if none was active.

Describe the solution you'd like
A "Hooks" section in the README that lists the hook scripts, their registration functions and variables, says when they run, and gives a short example of an activate/deactivate hook pair that works in Bash, Zsh and Fish. It should link to the existing virtualenv-delete hook docs.

Describe alternatives you've considered
Adding this to the Pyenv wiki's Authoring plugins page instead. But the hook points belong to this plugin and change with its code, so they're better documented next to it, like the virtualenv-delete hooks already are.
[ ] In particular, did you consider writing a plugin? Note that if your plugin has general applicability, you can publish it in the 3rd-party plugin catalog on the Pyenv Wiki as per the link above.

  • Not applicable: this is about documenting the hook points that plugins use.

Additional context
I checked the behaviour described above with pyenv 2.8.15 and pyenv-virtualenv master (6fb661f) in Bash, Zsh and Fish 4.9.3, with manual and automatic activation.

Lenguaje dominante
Shell
Estrellas
6.7k
Forks
433
Merge medio
1 d 8 h
PR fusionados (30 d)
11

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de pyenv/pyenv-virtualenv

Todos los issues de pyenv/pyenv-virtualenv

Issues similares

Más issues de Shell/Bash

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.