This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: 'dirty' added to sys.version on Linux and Mac source builds depending on git version
Type: enhancement Stage:
Components: Build Versions: Python 3.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: mark.final, ned.deily
Priority: normal Keywords:

Created on 2021-06-15 10:27 by mark.final, last changed 2022-04-11 14:59 by admin.

Messages (1)
msg395866 - (view) Author: Mark Final (mark.final) Date: 2021-06-15 10:27
Hi,

We build Python 3.7 from source in-house for Windows, Linux and macOSX.

It's been noticed that 'dirty' has been appended to sys.version in our builds, even though the source tree has not been modified from a git clone. This only happens for Linux and macOSX.

I traced this to the following commands (which are unchanged in main):

https://github.com/python/cpython/blob/main/configure#L2833
https://github.com/python/cpython/blob/main/configure.ac#L50

> GITTAG="git --git-dir \$(srcdir)/.git describe --all --always --dirty"

I further traced it to behaviours of different versions of git. In particular, when git is invoked outside of the working tree, and --git-dir is used alone, 'dirty' is always appended.

It's been noticed in a number of places online, including https://www.reddit.com/r/git/comments/4edtlx/git_describe_in_makefile_always_dirty/

Additionally using --work-tree does avoid the 'dirty' flag for a clean source tree, for git v2.21.0+.

I believe that this was this fix https://github.com/git/git/commit/a1e19004e11dcbc0ceebd92c425ceb1770e52d0b

However, since we do have usage of older versions of git, we've had to go with a different solution, which was to use git -C, i.e.

GITTAG="git -C \$(srcdir) describe --all --always --dirty"

so that git's working directory is changed to $(srcdir).

The other git commands in the code linked to do not seem to have the same issue, but we haven't changed them.

I'm writing this up in case anyone else has seen the issue, and offer the solution we found if it is useful.

Many thanks,
Mark
History
Date User Action Args
2022-04-11 14:59:46adminsetgithub: 88591
2021-06-16 01:01:50ned.deilysetnosy: + ned.deily
2021-06-15 10:27:55mark.finalcreate