diff --git a/setup.py b/setup.py index fe1edd0704aa832c1740607be98b6d4d078391c0..5d5c92f3573ce1c470dd59755cbfb4912c2e7d12 100755 --- a/setup.py +++ b/setup.py @@ -4,6 +4,7 @@ # """linkahead""" import os +import re import subprocess import sys @@ -103,12 +104,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.") + with open('src/linkahead/version.py') as fi: + for line in fi.readlines(): + match = re.match(r"^git_revision = (?P<rev>.*)$", line) + + if match is not None: + GIT_REVISION = match.group('rev') + else: GIT_REVISION = "Unknown"