From 2248fc54b512f988c60a907b3011c0cca04c3eba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20tom=20W=C3=B6rden?= <h.tomwoerden@indiscale.com> Date: Fri, 13 Oct 2023 09:41:59 +0200 Subject: [PATCH] MAINT: do not import linkahead during build --- setup.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/setup.py b/setup.py index 41a2c194..2b040aa0 100755 --- a/setup.py +++ b/setup.py @@ -4,6 +4,7 @@ # """linkahead""" import os +import re import subprocess import sys @@ -96,6 +97,7 @@ def get_version_info(): FULLVERSION = VERSION # Magic which is only really needed in the pipelines. Therefore: a lot of dark pipeline magic. + GIT_REVISION = "Unknown" if os.path.exists('.git'): GIT_REVISION = git_version() elif os.path.exists('linkahead_pylib_commit'): @@ -103,14 +105,13 @@ def get_version_info(): GIT_REVISION = f.read().strip() elif os.path.exists('src/linkahead/version.py'): # must be a source distribution, use existing version file - try: - from linkahead.version import git_revision as GIT_REVISION - except ImportError: - raise ImportError("Unable to import git_revision. Try removing " - "src/linkahead/version.py and the build directory " - "before building.") - else: - GIT_REVISION = "Unknown" + with open('src/linkahead/version.py') as fi: + rev_pattern = re.compile(r"^git_revision = '(?P<rev>.*)'$") + for line in fi.readlines(): + match = rev_pattern.match(line) + if match is not None: + GIT_REVISION = match.group('rev') + break if not ISRELEASED: FULLVERSION += '.dev0+' + GIT_REVISION[:7] -- GitLab