Repository navigation
Conversation
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. |
|
This change may fix the regression described by @itamaro: #158608 (comment). |
|
|
|
Ok, I fixed the out-of-tree build (used by the Ubuntu CI for example). |
It's only needed in the Python script. Python.h defines PY_VERSION (via patchlevel.h).
|
Example of auto-generated // 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)]" |
|
Ah, the "WASI / build and test" job does cross-compile! Running the Later, running |
|
With the help of @zware, I managed to update the PCbuild project, to build Programs_getcompiler.c and generate Modules\getbuildinfo.h on Windows. |
|
Aha, test_freeze_simple_script() of test_tools fails on Ubuntu / build and test (ubuntu-26.04-arm) with: |
It's just missing quotes: I fixed it. |
* Use argparse for command line parsing. * Run _getcompiler if --compiler option is omitted. * Rename getbuildinfo.h variables.
|
Cool! The change now builds successfully on all GitHub Action jobs! I checked
Some Clang versions are quite verbose/long. I will update the PR to strip the 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.
Modules/getbuildinfo.cto build strings at build time, instead of runtime #158948