From c95ebccf7a7ef0e9a40edd6e158c30a487abe859 Mon Sep 17 00:00:00 2001 From: SendaoYan Date: Thu, 15 Oct 2026 10:59:11 +0800 Subject: [PATCH] gh-159440: Pass --work-tree to the git commands used for the version tag --git-dir alone does not imply a work tree, so in an out-of-tree build git checked the build directory, and every tracked file looked deleted: sys.version always carried a spurious "-dirty" suffix. --- .../Build/2026-10-15-11-20-48.gh-issue-159440.uIz6ms.rst | 3 +++ configure | 6 +++--- configure.ac | 6 +++--- 3 files changed, 9 insertions(+), 6 deletions(-) create mode 100644 Misc/NEWS.d/next/Build/2026-10-15-11-20-48.gh-issue-159440.uIz6ms.rst diff --git a/Misc/NEWS.d/next/Build/2026-10-15-11-20-48.gh-issue-159440.uIz6ms.rst b/Misc/NEWS.d/next/Build/2026-10-15-11-20-48.gh-issue-159440.uIz6ms.rst new file mode 100644 index 000000000000000..6c6cc43fd2e60d0 --- /dev/null +++ b/Misc/NEWS.d/next/Build/2026-10-15-11-20-48.gh-issue-159440.uIz6ms.rst @@ -0,0 +1,3 @@ +The version string reported by ``sys.version`` no longer carries a spurious +``-dirty`` suffix when CPython is built out-of-tree from a clean git checkout: +the build stamp now checks the source tree instead of the build directory. diff --git a/configure b/configure index a628d337003b1ef..217d8e135600e16 100755 --- a/configure +++ b/configure @@ -3694,9 +3694,9 @@ HAS_GIT=no-repository fi if test $HAS_GIT = found then - GITVERSION="git --git-dir \$(srcdir)/.git rev-parse --short HEAD" - GITTAG="git --git-dir \$(srcdir)/.git describe --all --always --dirty" - GITBRANCH="git --git-dir \$(srcdir)/.git name-rev --name-only HEAD" + GITVERSION="git --git-dir \$(srcdir)/.git --work-tree \$(srcdir) rev-parse --short HEAD" + GITTAG="git --git-dir \$(srcdir)/.git --work-tree \$(srcdir) describe --all --always --dirty" + GITBRANCH="git --git-dir \$(srcdir)/.git --work-tree \$(srcdir) name-rev --name-only HEAD" else GITVERSION="" GITTAG="" diff --git a/configure.ac b/configure.ac index cf01e6fa82bceb6..ca804d6448810d2 100644 --- a/configure.ac +++ b/configure.ac @@ -128,9 +128,9 @@ HAS_GIT=no-repository fi if test $HAS_GIT = found then - GITVERSION="git --git-dir \$(srcdir)/.git rev-parse --short HEAD" - GITTAG="git --git-dir \$(srcdir)/.git describe --all --always --dirty" - GITBRANCH="git --git-dir \$(srcdir)/.git name-rev --name-only HEAD" + GITVERSION="git --git-dir \$(srcdir)/.git --work-tree \$(srcdir) rev-parse --short HEAD" + GITTAG="git --git-dir \$(srcdir)/.git --work-tree \$(srcdir) describe --all --always --dirty" + GITBRANCH="git --git-dir \$(srcdir)/.git --work-tree \$(srcdir) name-rev --name-only HEAD" else GITVERSION="" GITTAG=""