From 0670c1581354a6329e802cef771416299b284e98 Mon Sep 17 00:00:00 2001 From: Nick Sweeting Date: Sat, 27 Apr 2019 17:49:54 -0400 Subject: [PATCH] fix setup.py when .git is not available --- setup.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 296f72d7..fd551566 100644 --- a/setup.py +++ b/setup.py @@ -8,9 +8,12 @@ with open("README.md", "r") as fh: script_dir = os.path.abspath(os.path.dirname(os.path.abspath(__file__))) VERSION = open(os.path.join(script_dir, 'VERSION'), 'r').read().strip() -GIT_HEAD = open(os.path.join(script_dir, '.git', 'HEAD'), 'r').read().strip().split(': ')[1] -GIT_SHA = open(os.path.join(script_dir, '.git', GIT_HEAD), 'r').read().strip()[:9] -PYPI_VERSION = "{}+{}".format(VERSION, GIT_SHA) +try: + GIT_HEAD = open(os.path.join(script_dir, '.git', 'HEAD'), 'r').read().strip().split(': ')[1] + GIT_SHA = open(os.path.join(script_dir, '.git', GIT_HEAD), 'r').read().strip()[:9] + PYPI_VERSION = "{}+{}".format(VERSION, GIT_SHA) +except: + PYPI_VERSION = VERSION with open(os.path.join(script_dir, 'archivebox', 'VERSION'), 'w+') as f: f.write(PYPI_VERSION)