[issue44425] 'dirty' added to sys.version on Linux and Mac source builds depending on git version

2021-06-15 Thread Ned Deily


Change by Ned Deily :


--
nosy: +ned.deily

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44425] 'dirty' added to sys.version on Linux and Mac source builds depending on git version

2021-06-15 Thread Mark Final


New submission from Mark Final :

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

--
components: Build
messages: 395866
nosy: mark.final
priority: normal
severity: normal
status: open
title: 'dirty' added to sys.version on Linux and Mac source builds depending on 
git version
type: enhancement
versions: Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com