sysconfig variable impermanence in virtual environment when cross-compiling
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 77.2k
- 派生
- 35.9k
- PR 合并指标
- PR 指标待抓取
描述
Bug report
Bug description:
The solution to issue GH-126789 (found in GH-127729 / 70154855cf69) introduced a side effect when sysconfig variables are fetched in a virtual environment with the _PYTHON_PROJECT_BASE environment variable present (on posix platforms). Specifically, every invocation of sysconfig.get_config_vars() and sysconfig.get_config_var() causes the variable cache to be reset and rebuilt from scratch. This can be confirmed by running Python as follows:
virtualenv -p /usr/bin/python3.14 env # 3.14 or higher
_PYTHON_PROJECT_BASE=/any/path env/bin/python
And then executing:
import sysconfig
sysconfig.get_config_vars()['LIBDIR'] = '/some/new/path'
assert sysconfig.get_config_var('LIBDIR') != '/some/new/path'
Rebuilding the variable cache every time is fairly inefficient and prevents the possibility of tweaking the values (a sometimes necessary evil).
CPython versions tested on:
3.14
Operating systems tested on:
Linux
Linked PRs
- gh-150164
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
使用提供的虚拟环境复现方式和 _PYTHON_PROJECT_BASE 设置,从 sysconfig.get_config_vars() 和 sysconfig.get_config_var() 开始。跟踪缓存为何会在每次调用时重建,添加回归测试覆盖,并验证修改后的值在后续查找中仍然保留。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- build-system
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100