Document the virtualenv, activate and deactivate hooks

Aperta Adatta ai principianti
#552 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@officialasishkumar ci sta già lavorando.

Dal 4/12/2026.

  • #553 di @officialasishkumar — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
82/100
Tipo di issue
Documentazione
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
bash, fish, shell, zsh
Ambito
documentation

Direzione di ricerca

Inizia dalla documentazione esistente dell’hook virtualenv-delete nel README, quindi leggi il codice di registrazione ed esecuzione degli hook per virtualenv, activate e deactivate per confermare i nomi degli hook, le variabili e il comportamento della shell descritti nell’issue. Aggiungi una sezione Hooks con questi dettagli, un esempio di activate/deactivate per Bash, Zsh e Fish e un link alla documentazione esistente di virtualenv-delete. Il lavoro è completato quando i punti di aggancio documentati e l’esempio corrispondono al comportamento descritto nell’issue.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Shell
Stelle
6.7k
Fork
433
Merge medio
1g 8h
PR unite (30g)
11

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di pyenv/pyenv-virtualenv

Tutte le issue di pyenv/pyenv-virtualenv

Issue simili

Altre issue su Shell/Bash

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.