Document the virtualenv, activate and deactivate hooks

未关闭 适合新手
#552 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@officialasishkumar 已经在做这个了。

开始于 2026年12月4日。

  • #553 来自 @officialasishkumar —— 未关闭

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
82/100
Issue 类型
文档
描述清晰度
描述清楚
活跃度
活跃
技术栈
bash, fish, shell, zsh
领域
documentation

调研方向

从 README 中现有的 virtualenv-delete hook 文档开始,然后阅读 virtualenv、activate 和 deactivate 的 hook 注册与执行代码,以确认 issue 中描述的 hook 名称、变量和 shell 行为。添加一个 Hooks 部分,包含这些详细信息、Bash、Zsh 和 Fish 的 activate/deactivate 示例,以及指向现有 virtualenv-delete 文档的链接。当文档中的 hook 点和示例与 issue 所述行为相符时,即为完成。

由索引模型根据 Issue 内容生成。

描述

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.

主要语言
Shell
星标
6.7k
派生
433
平均合并
1 天 8 小时
30 天内合并 PR
11

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

pyenv/pyenv-virtualenv 的其他 Issue

查看 pyenv/pyenv-virtualenv 的全部 Issue

相似的 Issue

更多 Shell/Bash Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。