python / python/cpython

build-details.json is incorrect when using ./configure --with-build-python on a non-cross build

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

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

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

Mô tả

Bug report

Bug description:

We noticed that python-build-standalone's build-details.json contains "platform": "" on non-cross builds.

I think I know why. For consistency (I think), python-build-standalone always uses ./configure --with-build-python on both cross builds and normal builds.

This causes configure.ac to do

    PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(srcdir)/Lib _PYTHON_SYSCONFIGDATA_NAME=_sysconfigdata_$(ABIFLAGS)_$(MACHDEP)_$(MULTIARCH) _PYTHON_SYSCONFIGDATA_PATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`) '$with_build_python

(line 167 in 3.15.0a1), as opposed to PYTHON_FOR_BUILD='./$(BUILDPYTHON) -E' in the without-build-python case.

However, $_PYTHON_HOST_PLATFORM is only actually set to something in the cross-compile case (line 820 in 3.15.0a1), meaning that $PYTHON_FOR_BUILD is effectively doing _PYTHON_HOST_PLATFORM= python3.

The fact that this variable is an empty string, in turn, causes sysconfig.get_platform() to return an empty string:

$ uvx python3.15
Python 3.15.0a1 (main, Oct 14 2025, 21:28:08) [Clang 20.1.4 ] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sysconfig
>>> sysconfig.get_platform()
'linux-x86_64'
>>> import os
>>> os.environ['_PYTHON_HOST_PLATFORM'] = ''
>>> sysconfig.get_platform()
''

which makes generate-build-details.py output an empty string.

Arguably this is two bugs: configure.ac should not set _PYTHON_HOST_PLATFORM to an empty string, and sysconfig should not misbehave if _PYTHON_HOST_PLATFORM is set to an empty string (and should treat that as equivalent to being unset). Or maybe only one of these is a bug and the other is intended behavior. Also, of course, generate-build-details.py could work around this itself. I'm happy to provide a PR for any or all of these given some feedback on which direction to take this.

This applies to 3.14+ (all versions with build-details.json). If it's helpful, here are our full build logs for 3.14 and 3.15 in GHA; expand the "Build" section and search for generate-build-details. I've patched generate-build-details.py with print(f"generate-build-details debug: {sysconfig=} {sysconfig.get_platform()=}", file=sys.stderr).

(FYI I am probably about to file another bug about build-details.json generation in a moment, which might have a related cause and influence what the fix should be. EDIT: was already reported, #136267, left some analysis there)

CPython versions tested on:

3.14

Operating systems tested on:

Linux

Linked PRs
  • gh-142375

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

Đọc configure.ac và generate-build-details.py, sau đó kiểm tra hành vi đã được báo cáo của _PYTHON_HOST_PLATFORM và sysconfig.get_platform() đối với các bản build không cross. So sánh build log của 3.14 và 3.15 cùng issue liên quan #136267. Hoàn thành có nghĩa là các bản build không cross tạo ra platform chính xác trong build-details.json mà không gây hồi quy cho các bản build cross.

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
build-system
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.