| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Merge Python/getcompiler.c, Python/getcopyright.c, Python/getplatform.c and Python/getversion.c into Modules/getbuildinfo.c. Add Tools/build/generate_getbuildinfo.py to auto-generate a new Module/getbuildinfo.h header file which contains build information strings.
|
This PR is a draft. I didn't investigate Windows support yet. I didn't try cross-compilation, it may break. |
Sorry, something went wrong.
|
This change may fix the regression described by @itamaro: #158608 (comment). |
Sorry, something went wrong.
|
Tools/build/generate_getbuildinfo.py the SOURCE_DATE_EPOCH environment variable for reproducible build: https://reproducible-builds.org/specs/source-date-epoch/. If it's set, use it for the date and time. |
Sorry, something went wrong.
|
Ok, I fixed the out-of-tree build (used by the Ubuntu CI for example). |
Sorry, something went wrong.
It's only needed in the Python script. Python.h defines PY_VERSION (via patchlevel.h).
|
Example of auto-generated Modules/getbuildinfo.h header file: // Header file auto-generated by Tools/build/generate_getbuildinfo.py
#define DATE "Oct 7 2026"
#define TIME "05:35:34"
#define COMPILER "[GCC 16.2.1 20260819 (Red Hat 16.2.1-2)]"
#define PLATFORM "linux"
#define GITBRANCH "getbuildinfo"
#define GITTAG "heads/getbuildinfo"
#define GITVERSION "22d1a6b7c1e"
#define GIT_IDENTIFIER "heads/getbuildinfo"
#define BUILDINFO "heads/getbuildinfo:22d1a6b7c1e, Oct 7 2026, 05:35:34"
#define GET_VERSION "3.16.0a0 (heads/getbuildinfo:22d1a6b7c1e, Oct 7 2026, 05:35:34) [GCC 16.2.1 20260819 (Red Hat 16.2.1-2)]" |
Sorry, something went wrong.
|
Ah, the "WASI / build and test" job does cross-compile! Running the Programs/_getcompiler program to get the compiler version fails with Exec format error. /home/runner/work/cpython/cpython/cross-build/aarch64-unknown-linux-gnu/python ../../Tools/build/generate_getbuildinfo.py Modules/getbuildinfo.h \ "wasi" \ `LC_ALL=C git --git-dir ../../.git rev-parse --short HEAD` \ `LC_ALL=C git --git-dir ../../.git describe --all --always --dirty` \ `LC_ALL=C git --git-dir ../../.git name-rev --name-only HEAD` \ "`Programs/_getcompiler`" (...) /bin/sh: 1: Programs/_getcompiler: Exec format error Later, running test.pythinfo fails on collect_platform() because sys.version lacks the compiler: ERROR: collect_platform() failed
Traceback (most recent call last):
File "/Lib/test/pythoninfo.py", line 1418, in collect_info
collect_func(info_add)
~~~~~~~~~~~~^^^^^^^^^^
File "/Lib/test/pythoninfo.py", line 185, in collect_platform
platform.python_implementation())
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
File "/Lib/platform.py", line 1199, in python_implementation
return _sys_version()[0]
~~~~~~~~~~~~^^
File "/Lib/platform.py", line 1159, in _sys_version
raise ValueError(
'failed to parse CPython sys.version: %s' %
repr(sys_version))
ValueError: failed to parse CPython sys.version: '3.16.0a0 (remotes/pull/158951/merge-dirty:00e222b, Oct 7 2026, 03:37:58) '
|
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Merge Python/getcompiler.c, Python/getcopyright.c, Python/getplatform.c and Python/getversion.c into
Modules/getbuildinfo.c.
Add Tools/build/generate_getbuildinfo.py to auto-generate a new Module/getbuildinfo.h header file which contains build information strings.