FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-158948: Add auto-generated Module/getbuildinfo.h by vstinner · Pull Request #158951 · python/cpython · GitHub

Repository navigation

gh-158948: Add auto-generated Module/getbuildinfo.h - #158951

Draft
vstinner wants to merge 9 commits into
python:mainfrom
vstinner:getbuildinfo
Draft

vstinner wants to merge 9 commits into
python:mainfrom
vstinner:getbuildinfo

Conversation

vstinner commented Oct 7, 2026 •
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Member

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.

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.

vstinner commented Oct 7, 2026

Copy link
Copy Markdown
Member Author

This PR is a draft. I didn't investigate Windows support yet. I didn't try cross-compilation, it may break.

vstinner commented Oct 7, 2026

Copy link
Copy Markdown
Member Author

This change may fix the regression described by @itamaro: #158608 (comment).

vstinner commented Oct 7, 2026

Copy link
Copy Markdown
Member Author

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.

vstinner commented Oct 7, 2026

Copy link
Copy Markdown
Member Author

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).

vstinner commented Oct 7, 2026

Copy link
Copy Markdown
Member Author

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)]"

vstinner commented Oct 7, 2026 •
edited
Loading

Copy link
Copy Markdown
Member Author

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) '

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant


Back | FazBrowse Home | New Git URL