From 792101819a44155779d0d52c913697a81842063d Mon Sep 17 00:00:00 2001 From: Marc Bonnici Date: Tue, 12 Jan 2021 17:04:37 +0000 Subject: [PATCH] utils/version: Prevent installation failure on systems without git On systems that do not have git installed devlib will currently fail to install with a FileNotFound Exception. If git is not present then we will not have a commit hash so just ignore this error. --- devlib/utils/version.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/devlib/utils/version.py b/devlib/utils/version.py index 64b8cea..864eda7 100644 --- a/devlib/utils/version.py +++ b/devlib/utils/version.py @@ -33,8 +33,11 @@ def get_devlib_version(): def get_commit(): - p = Popen(['git', 'rev-parse', 'HEAD'], cwd=os.path.dirname(__file__), - stdout=PIPE, stderr=PIPE) + try: + p = Popen(['git', 'rev-parse', 'HEAD'], cwd=os.path.dirname(__file__), + stdout=PIPE, stderr=PIPE) + except FileNotFoundError: + return None std, _ = p.communicate() p.wait() if p.returncode: