Document the virtualenv, activate and deactivate hooks

Đang mở Phù hợp với người mới
#552 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@officialasishkumar đang làm issue này rồi.

Từ ngày 4/12/2026.

  • #553 của @officialasishkumar — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
82/100
Loại issue
Tài liệu
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
bash, fish, shell, zsh
Lĩnh vực
documentation

Hướng nghiên cứu

Bắt đầu với tài liệu hiện có về hook virtualenv-delete trong README, sau đó đọc mã đăng ký và thực thi hook cho virtualenv, activate và deactivate để xác nhận tên hook, biến và hành vi shell được mô tả trong issue. Thêm phần Hooks với các chi tiết đó, ví dụ activate/deactivate cho Bash, Zsh và Fish, cùng liên kết đến tài liệu virtualenv-delete hiện có. Hoàn tất khi các điểm hook được ghi lại và ví dụ khớp với hành vi được mô tả trong issue.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Shell
Star
6.7k
Fork
433
Merge trung bình
1 ngày 8 giờ
Pull request đã merge (30 ngày)
11

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của pyenv/pyenv-virtualenv

Tất cả issue của pyenv/pyenv-virtualenv

Issue tương tự

Thêm issue về Shell/Bash

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.