python / python/cpython

Nested virtual environment support in site/venv modules

オープン
#129,445 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

stdlib topic-venv type-feature
主要言語
Python
スター
77.2k
フォーク
35.9k
PR マージ指標
PR 指標を取得中

説明

Feature or enhancement

Proposal:

It's a bit of a niche use case, but it would be helpful if you could have one virtual environment be created that references another as its parent. If you currently attempt to do this, the pyvenv.cfg of the child virtual environment only indirectly references the parent through the command variable (which doesn't appear to be used). The code in site.venv could be enhanced to infer the prefix of the parent environment and add those site packages after the current virtual environment. This would ensure that the order of sys.path entries would be appropriate.

This would allow you to create a group virtual environment with a lot of common packages and still allow users to have their own child environments with additional or newer packages.

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

issue で参照されている site.venv の実装がある Lib/site.py から始め、pyvenv.cfg と command 変数が現在どのように扱われているかを確認します。子環境が親のプレフィックスをどのように推測し、親の site packages を子のエントリの後に配置するかを定義します。ネストされた環境で意図した sys.path の順序が公開されれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
developer-experience
issue の種類
機能追加
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
38/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。