https://github.com/python/cpython/commit/637fb369c751efb0564e35757318e72874e21619
commit: 637fb369c751efb0564e35757318e72874e21619
branch: main
author: sendaoYan <[email protected]>
committer: itamaro <[email protected]>
date: 2026-10-14T21:17:52-07:00
summary:
gh-159440: Pass --work-tree to the git commands used for the version tag
(#159442)
`--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.
files:
A Misc/NEWS.d/next/Build/2026-10-15-11-20-48.gh-issue-159440.uIz6ms.rst
M configure
M configure.ac
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=""
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]