From 03992630b5f4d0ce44735ce689af3f6f70dfecec Mon Sep 17 00:00:00 2001 From: Yu Yang Date: Wed, 7 Nov 2018 17:25:54 +0800 Subject: [PATCH] fix(py): set `cwd` when get commit sha in setup.py (#14299) `cwd` was not set before when get commit SHA. The default `cwd` is the current build directory. However, the build directory might not be the subdirectory of source. The `git` command will fail when that happened. test=develop --- python/setup.py.in | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/python/setup.py.in b/python/setup.py.in index ee19294ad5..b1ff9f3a5c 100644 --- a/python/setup.py.in +++ b/python/setup.py.in @@ -14,7 +14,8 @@ RC = 0 def git_commit(): try: cmd = ['git', 'rev-parse', 'HEAD'] - git_commit = subprocess.Popen(cmd, stdout = subprocess.PIPE).communicate()[0].strip() + git_commit = subprocess.Popen(cmd, stdout = subprocess.PIPE, + cwd="@PADDLE_SOURCE_DIR@").communicate()[0].strip() except: git_commit = 'Unknown' git_commit = git_commit.decode() @@ -44,7 +45,7 @@ def get_patch(): def is_taged(): try: cmd = ['git', 'describe', '--exact-match', '--tags', 'HEAD', '2>/dev/null'] - git_tag = subprocess.Popen(cmd, stdout = subprocess.PIPE).communicate()[0].strip() + git_tag = subprocess.Popen(cmd, stdout = subprocess.PIPE, cwd="@PADDLE_SOURCE_DIR@").communicate()[0].strip() git_tag = git_tag.decode() except: return False @@ -55,8 +56,7 @@ def is_taged(): return False def write_version_py(filename='paddle/version.py'): - cnt = ''' -# THIS FILE IS GENERATED FROM PADDLEPADDLE SETUP.PY + cnt = '''# THIS FILE IS GENERATED FROM PADDLEPADDLE SETUP.PY # full_version = '%(major)d.%(minor)d.%(patch)s' major = '%(major)d' -- GitLab