mirror of
https://github.com/ARM-software/devlib.git
synced 2025-01-31 10:10:46 +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:
parent
b0db2067a2
commit
441eea9897
@ -53,10 +53,10 @@ from devlib.host import LocalConnection
|
|||||||
from devlib.utils.android import AdbConnection
|
from devlib.utils.android import AdbConnection
|
||||||
from devlib.utils.ssh import SshConnection, TelnetConnection, Gem5Connection
|
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()
|
__commit = __get_commit()
|
||||||
if __commit:
|
if __commit:
|
||||||
|
@ -15,8 +15,23 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
from collections import namedtuple
|
||||||
from subprocess import Popen, PIPE
|
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():
|
def get_commit():
|
||||||
p = Popen(['git', 'rev-parse', 'HEAD'], cwd=os.path.dirname(__file__),
|
p = Popen(['git', 'rev-parse', 'HEAD'], cwd=os.path.dirname(__file__),
|
||||||
stdout=PIPE, stderr=PIPE)
|
stdout=PIPE, stderr=PIPE)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user