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
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List:, ned.deily
Priority: normal Keywords:

Created on 2021-06-15 10:27 by, last changed 2021-06-16 01:01 by ned.deily.

Messages (1)
msg395866 - (view) Author: Mark Final ( Date: 2021-06-15 10:27

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

> 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

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

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,
Date User Action Args
2021-06-16 01:01:50ned.deilysetnosy: + ned.deily
2021-06-15 10:27:55mark.finalcreate