sysconfig.get_path('platstdlib') return paths in virtual environments (or otherwise weird)
還沒有人認領這個 Issue。
- 主要語言
- Python
- 星號
- 77.2k
- 分支
- 36k
- 平均合併
- 1 天 9 小時
- 30 天內合併 PR
- 558
描述
Bug report
The sysconfig.get_path function is supposed to return he following for its first argument:
stdlib: directory containing the standard Python library files that are not platform-specific.platstdlib: directory containing the standard Python library files that are platform-specific.
E.g. in the python:3.11.1 Docker container:
>>> import sysconfig
>>> sysconfig.get_path('stdlib')
'/usr/local/lib/python3.11'
>>> sysconfig.get_path('platstdlib')
'/usr/local/lib/python3.11'
Or on a Python build configured with lib64 platlibdir (e.g. on Fedora Linux with $RPM_BUILD_ROOT environment variable set):
>>> import sysconfig
>>> sysconfig.get_path('stdlib')
'/usr/lib64/python3.11'
>>> sysconfig.get_path('platstdlib')
'/usr/lib64/python3.11'
Yet in virtual environments, the platstdlib directory returns a directory from within the virtual environment. E.g. in the python:3.11.1 Docker container:
>>> import sysconfig
>>> sysconfig.get_path('stdlib')
'/usr/local/lib/python3.11'
>>> sysconfig.get_path('platstdlib')
'.../myvenv/lib/python3.11'
Or on Fedora Linux:
>>> import sysconfig
>>> sysconfig.get_path('stdlib')
'/usr/lib64/python3.11'
>>> sysconfig.get_path('platstdlib')
'.../myvenv/lib64/python3.11'
This even confuses the default values on Fedora Linux (without $RPM_BUILD_ROOT environment variable set):
>>> import sysconfig
>>> sysconfig.get_path('stdlib')
'/usr/lib64/python3.11'
>>> sysconfig.get_path('platstdlib')
'/usr/local/lib64/python3.11'
I believe that here:
https://github.com/python/cpython/blob/62251c3da06eb4662502295697f39730565b1717/Lib/sysconfig.py#L30
The {platbase} variable should be replaced with {insatlled_base} or even (currently AFAIK nonexistent) {insatlled_platbase}.
Your environment
- CPython versions tested on: 3.11.1
- Operating system and architecture: Fedora Linux 37 x86_64, python:3.11.1 Docker container.
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
從 Lib/sysconfig.py 第 30 行附近開始,在虛擬環境、Python 3.11.1 Docker 映像和 Fedora Linux 中重現回報的 sysconfig.get_path('stdlib') 和 get_path('platstdlib') 結果。完成的標準是:這些環境中的平台特定標準函式庫路徑與文件所述的區別一致,並在現有測試套件處理 sysconfig 路徑的地方加入回歸測試涵蓋範圍。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- python
- 領域
- tooling
- Issue 類型
- 缺陷
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100