From 2efa83bc4da737e9544c39a4c495df7990f6ac79 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 1 Apr 2018 20:33:06 +0530 Subject: [PATCH] Use git rev-parse instead, more robust --- setup.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 7d547b63d..cc188f1ec 100755 --- a/setup.py +++ b/setup.py @@ -183,8 +183,7 @@ def init_env( sysconfig.get_config_var('CCSHARED') ) if os.path.exists('.git'): - head = open('.git/HEAD', 'r').read().split(':', 1)[-1].strip() - rev = open('.git/' + head).read().split(':', 1)[-1].strip() + rev = subprocess.check_output(['git', 'rev-parse', 'HEAD']).decode('utf-8').strip() cflags.append('-DKITTY_VCS_REV="{}"'.format(rev)) ldflags = os.environ.get( 'OVERRIDE_LDFLAGS',