diff --git a/devlib/__init__.py b/devlib/__init__.py index af8a336..a6b4647 100644 --- a/devlib/__init__.py +++ b/devlib/__init__.py @@ -30,3 +30,14 @@ from devlib.trace.serial_trace import SerialTraceCollector 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_commit as __get_commit + + +__version__ = '0.0.4' + +__commit = __get_commit() +if __commit: + __full_version__ = '{}-{}'.format(__version__, __commit) +else: + __full_version__ = __version__ diff --git a/setup.py b/setup.py index 14fcf3e..2109d58 100644 --- a/setup.py +++ b/setup.py @@ -13,6 +13,7 @@ # limitations under the License. # +import imp import os import sys import warnings @@ -37,6 +38,26 @@ try: 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) + + packages = [] data_files = {} source_dir = os.path.dirname(__file__) @@ -59,7 +80,7 @@ for root, dirs, files in os.walk(devlib_dir): params = dict( name='devlib', description='A framework for automating workload execution and measurment collection on ARM devices.', - version='0.0.4', + version=__version__, packages=packages, package_data=data_files, url='https://github.com/ARM-software/devlib',