python / python/cpython

sysconfig.get_path('platstdlib') return paths in virtual environments (or otherwise weird)

Đang mở
#101,500 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

topic-sysconfig type-bug
Ngôn ngữ chính
Python
Star
77.2k
Fork
36k
Chỉ số merge pull request
Chỉ số pull request đang chờ

Mô tả

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.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu trong Lib/sysconfig.py, khoảng dòng 30, và tái hiện các kết quả được báo cáo của sysconfig.get_path('stdlib') và get_path('platstdlib') trong một môi trường ảo, image Docker Python 3.11.1 và Fedora Linux. Được xem là hoàn tất khi đường dẫn thư viện chuẩn dành riêng cho nền tảng nhất quán với sự phân biệt được ghi trong tài liệu trên các môi trường này, đồng thời bổ sung kiểm thử hồi quy tại nơi bộ kiểm thử hiện có xử lý các đường dẫn sysconfig.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
python
Lĩnh vực
tooling
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.