1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2025-01-31 10:11:17 +00:00

fw/version: Introduce required version for devlib

To ensure that a compatible version of devlib is installed on the system
keep track of the version of devlib that is required by WA and provide a
more useful error message if this is not satisfied.
This commit is contained in:
Marc Bonnici 2019-02-20 11:53:09 +00:00
parent bedd3bf062
commit adb3ffa6aa
3 changed files with 29 additions and 10 deletions

View File

@ -29,7 +29,8 @@ except ImportError:
wa_dir = os.path.join(os.path.dirname(__file__), 'wa') wa_dir = os.path.join(os.path.dirname(__file__), 'wa')
sys.path.insert(0, os.path.join(wa_dir, 'framework')) sys.path.insert(0, os.path.join(wa_dir, 'framework'))
from version import get_wa_version, get_wa_version_with_commit from version import (get_wa_version, get_wa_version_with_commit,
format_version, required_devlib_version)
# happens if falling back to distutils # happens if falling back to distutils
warnings.filterwarnings('ignore', "Unknown distribution option: 'install_requires'") warnings.filterwarnings('ignore', "Unknown distribution option: 'install_requires'")
@ -83,7 +84,7 @@ params = dict(
'colorama', # Printing with colors 'colorama', # Printing with colors
'pyYAML', # YAML-formatted agenda parsing 'pyYAML', # YAML-formatted agenda parsing
'requests', # Fetch assets over HTTP 'requests', # Fetch assets over HTTP
'devlib>=1.1.dev1', # Interacting with devices 'devlib>={}'.format(format_version(required_devlib_version)), # Interacting with devices
'louie-latest', # callbacks dispatch 'louie-latest', # callbacks dispatch
'wrapt', # better decorators 'wrapt', # better decorators
'pandas>=0.23.0', # Data analysis and manipulation 'pandas>=0.23.0', # Data analysis and manipulation
@ -123,7 +124,6 @@ class sdist(orig_sdist):
orig_sdist.initialize_options(self) orig_sdist.initialize_options(self)
self.strip_commit = False self.strip_commit = False
def run(self): def run(self):
if self.strip_commit: if self.strip_commit:
self.distribution.get_version = get_wa_version self.distribution.get_version = get_wa_version

View File

@ -21,14 +21,19 @@ import os
import warnings import warnings
import devlib import devlib
try:
from devlib.utils.version import version as installed_devlib_version
except ImportError:
installed_devlib_version = None
from wa.framework import pluginloader from wa.framework import pluginloader
from wa.framework.command import init_argument_parser from wa.framework.command import init_argument_parser
from wa.framework.configuration import settings from wa.framework.configuration import settings
from wa.framework.configuration.execution import ConfigManager from wa.framework.configuration.execution import ConfigManager
from wa.framework.host import init_user_directory, init_config from wa.framework.host import init_user_directory, init_config
from wa.framework.exception import ConfigError from wa.framework.exception import ConfigError, HostError
from wa.framework.version import get_wa_version_with_commit from wa.framework.version import (get_wa_version_with_commit, format_version,
required_devlib_version)
from wa.utils import log from wa.utils import log
from wa.utils.doc import format_body from wa.utils.doc import format_body
@ -64,6 +69,13 @@ def split_joined_options(argv):
return output return output
# Instead of presenting an obscure error due to a version mismatch explicitly warn the user.
def check_devlib_version():
if not installed_devlib_version or installed_devlib_version < required_devlib_version:
msg = 'WA requires Devlib version >={}. Please update the currently installed version {}'
raise HostError(msg.format(format_version(required_devlib_version), devlib.__version__))
def main(): def main():
if not os.path.exists(settings.user_directory): if not os.path.exists(settings.user_directory):
init_user_directory() init_user_directory()
@ -102,6 +114,7 @@ def main():
logger.debug('Version: {}'.format(get_wa_version_with_commit())) logger.debug('Version: {}'.format(get_wa_version_with_commit()))
logger.debug('devlib version: {}'.format(devlib.__full_version__)) logger.debug('devlib version: {}'.format(devlib.__full_version__))
logger.debug('Command Line: {}'.format(' '.join(sys.argv))) logger.debug('Command Line: {}'.format(' '.join(sys.argv)))
check_devlib_version()
# each command will add its own subparser # each command will add its own subparser
subparsers = parser.add_subparsers(dest='command') subparsers = parser.add_subparsers(dest='command')

View File

@ -23,13 +23,19 @@ VersionTuple = namedtuple('Version', ['major', 'minor', 'revision', 'dev'])
version = VersionTuple(3, 1, 1, 'dev1') version = VersionTuple(3, 1, 1, 'dev1')
required_devlib_version = VersionTuple(1, 1, 0, 'dev1')
def format_version(v):
version_string = '{}.{}.{}'.format(
v.major, v.minor, v.revision)
if v.dev:
version_string += '.{}'.format(v.dev)
return version_string
def get_wa_version(): def get_wa_version():
version_string = '{}.{}.{}'.format( return format_version(version)
version.major, version.minor, version.revision)
if version.dev:
version_string += '.{}'.format(version.dev)
return version_string
def get_wa_version_with_commit(): def get_wa_version_with_commit():