René's URL Explorer Experiment


Title: Out-of-tree builds always report a "-dirty" git tag in sys.version · Issue #159440 · python/cpython · GitHub

Open Graph Title: Out-of-tree builds always report a "-dirty" git tag in sys.version · Issue #159440 · python/cpython

X Title: Out-of-tree builds always report a "-dirty" git tag in sys.version · Issue #159440 · python/cpython

Description: Bug report sys.version embeds the output of git describe --all --always --dirty, which is compiled into the interpreter via -DGITTAG (Modules/getbuildinfo.o recipe in Makefile.pre.in). When CPython is built out-of-tree, that tag is alway...

Open Graph Description: Bug report sys.version embeds the output of git describe --all --always --dirty, which is compiled into the interpreter via -DGITTAG (Modules/getbuildinfo.o recipe in Makefile.pre.in). When CPython...

X Description: Bug report sys.version embeds the output of git describe --all --always --dirty, which is compiled into the interpreter via -DGITTAG (Modules/getbuildinfo.o recipe in Makefile.pre.in). When CPython...

Opengraph URL: https://github.com/python/cpython/issues/159440

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Out-of-tree builds always report a \"-dirty\" git tag in sys.version","articleBody":"### Bug report\n\n`sys.version` embeds the output of `git describe --all --always --dirty`, which is compiled into the interpreter via `-DGITTAG` (`Modules/getbuildinfo.o` recipe in `Makefile.pre.in`). When CPython is built **out-of-tree**, that tag is always reported as `-dirty`, even when the source checkout has no local modifications, because `configure.ac` passes `--git-dir` without `--work-tree`.\n\n#### Reproduction\n\n```console\n$ git -C ~/git/cpython status --short    # clean checkout, no output\n$ mkdir -p ~/build/cpython && cd ~/build/cpython\n$ bash ~/git/cpython/configure --prefix=$HOME/opt/cpython > /dev/null\n$ make -j && make install -j\n$ ~/opt/cpython/bin/python3 -VV\nPython 3.16.0a1+dev (heads/main-dirty:25883627946, Oct 14 2026, 22:17:06) [GCC 11.4.0]\n                            ^^^^^\n```\n\nThe -dirty suffix is bogus: the checkout is at 25883627946b7cbcf7286acfe2a2019382375325 with an unmodified work tree.\n\n#### Root cause\nconfigure.ac defines the git commands used for the build stamp:\n\n```bash\nGITVERSION=\"git --git-dir \\$(srcdir)/.git rev-parse --short HEAD\"\nGITTAG=\"git --git-dir \\$(srcdir)/.git describe --all --always --dirty\"\nGITBRANCH=\"git --git-dir \\$(srcdir)/.git name-rev --name-only HEAD\"\n```\n--git-dir only says where the repository is; it does not set the work tree, which therefore defaults to the current directory. In an out-of-tree build, make runs in the build directory, so the internal diff-index HEAD that implements git describe --dirty resolves every tracked path against the build directory, where none of them exist. Every tracked file is treated as deleted, and the tree is reported as dirty.\n\nRun from the build directory against a clean source tree:\n\n```\n$ cd ~/build/cpython\n$ git --git-dir=$HOME/git/cpython/.git diff-index --name-only HEAD | wc -l\n5490                                     # all tracked files appear deleted\n$ git --git-dir=$HOME/git/cpython/.git describe --all --always --dirty\nheads/main-dirty\n$ git --git-dir=$HOME/git/cpython/.git --work-tree=$HOME/git/cpython describe --all --always --dirty\nheads/main\n$ strings ~/build/cpython/Modules/getbuildinfo.o | grep heads/\nheads/main-dirty                         # the string that ends up in the binary\n```\nGITVERSION (rev-parse --short HEAD) and GITBRANCH (name-rev --name-only HEAD) are unaffected because they never touch the work tree — only the --dirty check is. In-tree builds are unaffected too, which is presumably why this went unnoticed.\n\n#### Proposed fix\nPass the work tree explicitly (equivalently, run git with -C $(srcdir)):\n\n```bash\nGITVERSION=\"git --git-dir \\$(srcdir)/.git --work-tree \\$(srcdir) rev-parse --short HEAD\"\nGITTAG=\"git --git-dir \\$(srcdir)/.git --work-tree \\$(srcdir) describe --all --always --dirty\"\nGITBRANCH=\"git --git-dir \\$(srcdir)/.git --work-tree \\$(srcdir) name-rev --name-only HEAD\"\n```\nThe suffix keeps its intended meaning: local modifications to the source tree are still reported, while an out-of-tree build of a clean checkout now reports a clean tag. In-tree builds are byte-for-byte unaffected since $(srcdir) is ..\n\n#### Workaround\nUntil this is fixed, an out-of-tree build can be nudged into reporting the right tag by overriding GITTAG and forcing Modules/getbuildinfo.o to be recompiled (it does not depend on Makefile, so reconfiguring alone will not rebuild it):\n\n```bash\n$ rm -f Modules/getbuildinfo.o\n$ make -j GITTAG=\"git --git-dir=$PWD/../cpython/.git --work-tree=$PWD/../cpython describe --all --always --dirty\"\n$ make install\n```\n\n#### Affected versions\n3.7 and later: --dirty was added by bpo-27593 (554626ada76, 2017-03-20) and first shipped in 3.7.0a1. Only out-of-tree builds are affected.\n\n\n\n\n\n\n### CPython versions tested on:\n\nCPython main branch\n\n### Operating systems tested on:\n\nLinux\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-159442\n* gh-159443\n* gh-159444\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/sendaoYan","@type":"Person","name":"sendaoYan"},"datePublished":"2026-10-15T02:22:36Z","url":"https://github.com/python/cpython/issues/159440"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:21a17f18-6f08-6acb-1fd7-af9765c8acfa
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id9218:28831:50BBCD:705DA1:6AFEA441
html-safe-nonce9f20347655722932c225246647b801b25f26bc33a834eca2f2ea375e523aeb4a
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MjE4OjI4ODMxOjUwQkJDRDo3MDVEQTE6NkFGRUE0NDEiLCJ2aXNpdG9yX2lkIjoiNTQ1MjMwNzU5MzYwNTA2Mzc0NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac7a2fccdba738439a0f5b8501544b9d7e651fede43ba08351a3e33a4b94646a06
hovercard-subject-tagissue:5858966873
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/159440/issue_layout
twitter:imagehttps://opengraph.githubassets.com/9a39d413e465594cd675d188b6818b088134662082cec2aeb71e8126940bb33d/python/cpython/issues/159440
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/9a39d413e465594cd675d188b6818b088134662082cec2aeb71e8126940bb33d/python/cpython/issues/159440
og:image:altBug report sys.version embeds the output of git describe --all --always --dirty, which is compiled into the interpreter via -DGITTAG (Modules/getbuildinfo.o recipe in Makefile.pre.in). When CPython...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamesendaoYan
hostnamegithub.com
expected-hostnamegithub.com
None95b2753c978240785d6cca00783c00a371b2d7d9879bb32e305170a1b19bd28e
turbo-cache-controlno-preview
go-importgithub.com/python/cpython git https://github.com/python/cpython.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id81598961
octolytics-dimension-repository_nwopython/cpython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id81598961
octolytics-dimension-repository_network_root_nwopython/cpython
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release3f25273206cd841171bca0002261ae4c9757d934
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/cpython/issues/159440#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F159440
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F159440
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/issues/159440
Reloadhttps://github.com/python/cpython/issues/159440
Reloadhttps://github.com/python/cpython/issues/159440
pythonhttps://github.com/python
cpythonhttps://github.com/python/cpython
Codehttps://github.com/python/cpython
Issues5k+ (5k+)https://github.com/python/cpython/issues
Pull requests2.4k (2.4k)https://github.com/python/cpython/pulls
Actionshttps://github.com/python/cpython/actions
Projectshttps://github.com/python/cpython/projects
Security and qualityhttps://github.com/python/cpython/security
Insightshttps://github.com/python/cpython/insights
https://github.com/python/cpython
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/159440
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/159440
Out-of-tree builds always report a "-dirty" git tag in sys.versionhttps://github.com/python/cpython/issues/159440#top
buildThe build process and cross-buildhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22build%22
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
https://github.com/sendaoYan
sendaoYanhttps://github.com/sendaoYan
on Oct 15, 2026https://github.com/python/cpython/issues/159440#issue-5858966873
2588362https://github.com/python/cpython/commit/25883627946b7cbcf7286acfe2a2019382375325
bpo-27593https://bugs.python.org/issue?@action=redirect&bpo=27593
554626ahttps://github.com/python/cpython/commit/554626ada769abf82a5dabe6966afa4265acb6a6
gh-159440: Pass --work-tree to the git commands used for the version tag #159442https://github.com/python/cpython/pull/159442
[3.15] gh-159440: Pass --work-tree to the git commands used for the version tag (GH-159442) #159443https://github.com/python/cpython/pull/159443
[3.14] gh-159440: Pass --work-tree to the git commands used for the version tag (GH-159442) #159444https://github.com/python/cpython/pull/159444
sendaoYanhttps://github.com/sendaoYan
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
on Oct 15, 2026https://github.com/python/cpython/issues/159440#event-33289642385
sendaoYanhttps://github.com/sendaoYan
on Oct 15, 2026https://github.com/python/cpython/issues/159440#event-33292574149
pythongh-159440: Pass --work-tree to the git commands used for the ve…https://github.com/sendaoYan/cpython-ysd/commit/290cd22694bb28a0506d91207259ad5ae501bd6f
pythongh-159440https://github.com/python/cpython/issues/159440
290cd22https://github.com/sendaoYan/cpython-ysd/commit/290cd22694bb28a0506d91207259ad5ae501bd6f
pythongh-159440: Pass --work-tree to the git commands used for the ve…https://github.com/sendaoYan/cpython-ysd/commit/ab9b4741e1709c0036d7a8c13e97380730261a0e
pythongh-159440https://github.com/python/cpython/issues/159440
ab9b474https://github.com/sendaoYan/cpython-ysd/commit/ab9b4741e1709c0036d7a8c13e97380730261a0e
pythongh-159440: Pass --work-tree to the git commands used for the ve…https://github.com/sendaoYan/cpython-ysd/commit/c95ebccf7a7ef0e9a40edd6e158c30a487abe859
pythongh-159440https://github.com/python/cpython/issues/159440
c95ebcchttps://github.com/sendaoYan/cpython-ysd/commit/c95ebccf7a7ef0e9a40edd6e158c30a487abe859
itamarohttps://github.com/itamaro
buildThe build process and cross-buildhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22build%22
on Oct 15, 2026https://github.com/python/cpython/issues/159440#event-33295676971
itamarohttps://github.com/itamaro
on Oct 15, 2026https://github.com/python/cpython/issues/159440#event-33295979225
gh-159440: Pass --work-tree to the git commands used for the version …https://github.com/python/cpython/commit/637fb369c751efb0564e35757318e72874e21619
gh-159440https://github.com/python/cpython/issues/159440
637fb36https://github.com/python/cpython/commit/637fb369c751efb0564e35757318e72874e21619
[3.14] gh-159440: Pass --work-tree to the git commands used for the v…https://github.com/python/cpython/commit/65feab817fb1f6e37aaaeb8b29ed4d4a8d41d67e
gh-159440https://github.com/python/cpython/issues/159440
65feab8https://github.com/python/cpython/commit/65feab817fb1f6e37aaaeb8b29ed4d4a8d41d67e
[3.15] gh-159440: Pass --work-tree to the git commands used for the v…https://github.com/python/cpython/commit/2337dd64b2b9f59fe335bf07641dd6c27651b91b
gh-159440https://github.com/python/cpython/issues/159440
2337dd6https://github.com/python/cpython/commit/2337dd64b2b9f59fe335bf07641dd6c27651b91b
https://github.com/sendaoYan
sendaoYanhttps://github.com/sendaoYan
on Oct 15, 2026https://github.com/python/cpython/issues/159440#issuecomment-6185835321
sendaoYanhttps://github.com/sendaoYan
completedhttps://github.com/python/cpython/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Oct 15, 2026https://github.com/python/cpython/issues/159440#event-33303422597
StanFromIrelandhttps://github.com/StanFromIreland
'dirty' added to sys.version on Linux and Mac source builds depending on git version #88591https://github.com/python/cpython/issues/88591
on Oct 22, 2026https://github.com/python/cpython/issues/159440#event-33921531938
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/cpython/issues/159440
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/cpython/issues/159440
buildThe build process and cross-buildhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22build%22
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.