1
0
mirror of https://github.com/ARM-software/devlib.git synced 2025-01-31 02:00:45 +00:00

devlib/version: Implement devlibs version as a namedtuple

Instead of defining devlibs versions as a string use a namedtuple and
add in a revision field.
This commit is contained in:
Marc Bonnici 2019-02-20 11:50:53 +00:00 committed by setrofim
parent b0db2067a2
commit 441eea9897
2 changed files with 17 additions and 2 deletions

View File

@ -53,10 +53,10 @@ 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
from devlib.utils.version import get_devlib_version, get_commit as __get_commit
__version__ = '1.1.dev1'
__version__ = get_devlib_version()
__commit = __get_commit()
if __commit:

View File

@ -15,8 +15,23 @@
import os
import sys
from collections import namedtuple
from subprocess import Popen, PIPE
VersionTuple = namedtuple('Version', ['major', 'minor', 'revision', 'dev'])
version = VersionTuple(1, 1, 0, 'dev1')
def get_devlib_version():
version_string = '{}.{}.{}'.format(
version.major, version.minor, version.revision)
if version.dev:
version_string += '.{}'.format(version.dev)
return version_string
def get_commit():
p = Popen(['git', 'rev-parse', 'HEAD'], cwd=os.path.dirname(__file__),
stdout=PIPE, stderr=PIPE)