venv.EnvBuilder creates inconsistent venv depending on the name of the Python executable
未关闭
还没有人认领这个 Issue。
stdlib
topic-venv
type-bug
- 主要语言
- Python
- 星标
- 77.2k
- 派生
- 35.9k
- PR 合并指标
- PR 指标待抓取
描述
Bug report
Bug description:
Given the below create-venv.py script and several Python 3 installed in the classpath:
import sys
import venv
if __name__ == "__main__":
venv.EnvBuilder().create(sys.argv[1])
Let’s create various venvs:
for VERSION in 3.9 3.11 3.12; do
python$VERSION create-venv.py $VERSION-venv
for EXEC in python python3 python$VERSION; do
$VERSION-venv/bin/$EXEC create-venv.py $VERSION-$EXEC-venv
done
done
And now, let’s check them:
for PYTHON in *-venv/bin/python; do
echo "$PYTHON: $($PYTHON --version)"
done
The above loop outputs:
3.11-python3.11-venv/bin/python: Python 3.11.7
3.11-python3-venv/bin/python: Python 3.9.14
3.11-python-venv/bin/python: Python 3.9.14
3.11-venv/bin/python: Python 3.11.7
3.12-python3.12-venv/bin/python: Python 3.12.1
3.12-python3-venv/bin/python: Python 3.9.14
3.12-python-venv/bin/python: Python 3.9.14
3.12-venv/bin/python: Python 3.12.1
3.9-python3.9-venv/bin/python: Python 3.9.14
3.9-python3-venv/bin/python: Python 3.9.14
3.9-python-venv/bin/python: Python 3.9.14
3.9-venv/bin/python: Python 3.9.14
As the reader can see, Python venv’s created by python or python3 executable of a Python venv will not use the Python of this venv, and instead will use the system’s default Python (3.9 in my case).
CPython versions tested on:
3.11, 3.12
Operating systems tested on:
Oracle Linux 9 and 10
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从提供的 create-venv.py 脚本和 venv.EnvBuilder 入口点开始,然后使用多个 Python 可执行文件名称运行 shell 循环,以复现解释器选择不一致的问题。跟踪用于调用 EnvBuilder 的可执行文件是如何被记录并在创建每个环境时使用的;当 venv 中的 python、python3 和带版本号的可执行文件都能一致地使用该 venv 的解释器创建环境时,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- tooling
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 冷清
- 描述清晰度
- 基本清楚
- 新手友好度
- 48/100