3.11 no longer builds with a configured empty prefix
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Lĩnh vực
- build-system
Hướng nghiên cứu
Tái hiện lỗi bằng ./configure --prefix= rồi chạy make, sau đó lần theo các giá trị prefix qua Modules/getpath.py, Modules/getpath.c, Python/initconfig.c và Python/sysmodule.c. So sánh quá trình chuyển đổi từ C sang Python với hành vi trước đây được đề cập trong issue. Được xem là hoàn thành khi CPython build thành công với prefix rỗng và các thuộc tính prefix bị ảnh hưởng vẫn có thể sử dụng được.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Bug report
In 3.11 is not possible to build by running ./configure with an empty prefix:
./configure --prefix=
After such configuration, running make fails with something similar to the following:
./_bootstrap_python ./Programs/_freeze_module.py abc ./Lib/abc.py Python/frozen_modules/abc.h
Fatal Python error: init_import_site: Failed to import the site module
Python runtime state: initialized
Traceback (most recent call last):
File "/home/etanol/Python-3.11.1/Lib/site.py", line 79, in <module>
PREFIXES = [sys.prefix, sys.exec_prefix]
^^^^^^^^^^
AttributeError: module 'sys' has no attribute 'prefix'
Makefile:1200: recipe for target 'Python/frozen_modules/abc.h' failed
Possible explanation
The sys module takes attributes like sys.exec and sys.exec_prefix from the PyConfig structure. However, if any of those values is NULL, the attribute does not seem to be defined.
During path calculation, the result of evaluating (the frozen version of) getpath.py is copied back to PyConfig. But the prefix and similar fields are treated by converting None to NULL (from the C macro expansion).
The prefix indicated to ./configure is passed on when compiling getpath.c. But empty strings are converted to None. If the evaluation of (frozen) getpath.py assigns None to the prefix global variable (and similar) what gets transferred back to getpath.c ends up becoming NULL in PyConfig.
I think an empty prefix worked in 3.10, and earlier, because the transition from C compiler macro to Python value preserved empty strings. Empty C strings were converted to empty Python strings; but 3.11 converts empty C strings to None.
Considerations
Using dummy values for ./configure --prefix and then controlling installation target with make DESTDIR=... is a fairly common practice when creating binary packages. It's very convenient as a way to build software inside sandboxed environments.
However, it is certainly arguable that allowing for an empty prefix may not be of interest (it's just as common to run ./configure --prefix=/).
It is also beyond my understanding to determine if the fix should be about preserving empty strings in the C to Python conversion or perhaps the logic in getpath.py should be modified with a last resort check to avoid setting prefix (and similar) to None.
Your environment
- CPython versions tested on: 3.11.1
- Operating system and architecture: Ubuntu 18.04 x86-64
- Ngôn ngữ chính
- Python
- Star
- 77.2k
- Fork
- 36k
- Merge trung bình
- 1 ngày 9 giờ
- Pull request đã merge (30 ngày)
- 558
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của python/cpython
-
docs pending
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
stdlib type-feature
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
stdlib type-feature
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
build type-bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
-
stdlib topic-email type-feature
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Tất cả issue của python/cpython
Issue tương tự
-
link-check link-check:sphinx-theme
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
qgis/QGIS-Documentation#11275 ·
-
bug priority:normal ready-for-dev
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
OpenHands/extensions#626 · 1 bình luận ·
-
Change observation tooltip text Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
CSCfi/sd-search-api#39 ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100