python / python/cpython

Issue warning when running an outdated virtual environment after updating Python in-place

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

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

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

説明

Feature or enhancement

Proposal:

Here's a virtual environment created with an older Python version (3.9, in this case):

$ cat test-env/pyvenv.cfg
home = /usr/bin
include-system-site-packages = false
version = 3.9.9
$ ls -n test-env/bin/
total 36
-rw-r--r-- 1 1000 985 1912 Jul 21 21:48 activate
-rw-r--r-- 1 1000 985  861 Jul 21 21:48 activate.csh
-rw-r--r-- 1 1000 985 2001 Jul 21 21:48 activate.fish
-rw-r--r-- 1 1000 985 8834 Jul 21 21:48 Activate.ps1
-rwxr-xr-x 1 1000 985  252 Jul 21 21:48 pip*
-rwxr-xr-x 1 1000 985  252 Jul 21 21:48 pip3*
-rwxr-xr-x 1 1000 985  252 Jul 21 21:48 pip3.9*
lrwxrwxrwx 1 1000 985   15 Jul 21 21:49 python -> /usr/bin/python*
lrwxrwxrwx 1 1000 985    6 Jul 21 21:50 python3 -> python*
lrwxrwxrwx 1 1000 985    6 Jul 21 21:51 python3.9 -> python*

After updating /usr/bin/python in-place (to 3.12.4, in this case), the environment runs without warnings.

$ test-env/bin/python
Python 3.12.4 (main, Jun  7 2024, 06:33:07) [GCC 14.1.1 20240522] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

The proposal here would be to, at least, issue a warning when the minor version of the version key in pyvenv.cfg is different from the running interpreter.

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 番号を参照したプルリクエストを送ります。

調査の方向性

pyvenv.cfg が Python 3.9.9 を示している一方で、test-env/bin/python が Python 3.12.4 に解決される test-env を使ってケースを再現します。test-env/bin/python から仮想環境の起動を追跡し、pyvenv.cfg がどのように読み取られるかを調べます。実行中のインタープリターと minor バージョンが異なる場合に警告が表示されれば完了です。

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

評価

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

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

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