From c0d8a98d90f4522065dde9a6b6f5e8e2d3452fef Mon Sep 17 00:00:00 2001 From: Marc Bonnici Date: Wed, 20 Feb 2019 14:05:32 +0000 Subject: [PATCH] setup.py: Use version_helper to generate devlib version Instead of parsing the text of the file to extract the current version use the version_helper to access the newly added version tuple. --- devlib/__init__.py | 5 +++-- setup.py | 24 +++++++----------------- 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/devlib/__init__.py b/devlib/__init__.py index 4deab24..da8d9e0 100644 --- a/devlib/__init__.py +++ b/devlib/__init__.py @@ -53,10 +53,11 @@ from devlib.host import LocalConnection from devlib.utils.android import AdbConnection from devlib.utils.ssh import SshConnection, TelnetConnection, Gem5Connection -from devlib.utils.version import get_devlib_version, get_commit as __get_commit +from devlib.utils.version import (get_devlib_version as __get_devlib_version, + get_commit as __get_commit) -__version__ = get_devlib_version() +__version__ = __get_devlib_version() __commit = __get_commit() if __commit: diff --git a/setup.py b/setup.py index 4571be2..757e450 100644 --- a/setup.py +++ b/setup.py @@ -41,23 +41,13 @@ except OSError: pass -with open(os.path.join(devlib_dir, '__init__.py')) as fh: - # Extract the version by parsing the text of the file, - # as may not be able to load as a module yet. - for line in fh: - if '__version__' in line: - parts = line.split("'") - __version__ = parts[1] - break - else: - raise RuntimeError('Did not see __version__') - - vh_path = os.path.join(devlib_dir, 'utils', 'version.py') - # can load this, as it does not have any devlib imports - version_helper = imp.load_source('version_helper', vh_path) - commit = version_helper.get_commit() - if commit: - __version__ = '{}+{}'.format(__version__, commit) +vh_path = os.path.join(devlib_dir, 'utils', 'version.py') +# can load this, as it does not have any devlib imports +version_helper = imp.load_source('version_helper', vh_path) +__version__ = version_helper.get_devlib_version() +commit = version_helper.get_commit() +if commit: + __version__ = '{}+{}'.format(__version__, commit) packages = []