diff --git a/bob/extension/scripts/click_helper.py b/bob/extension/scripts/click_helper.py index b0a4c69db6e20debb8c779a6439921a3b932126d..3513954bdbab7b2a321645c23710d45bcc6ff5dc 100644 --- a/bob/extension/scripts/click_helper.py +++ b/bob/extension/scripts/click_helper.py @@ -1,5 +1,6 @@ from ..log import set_verbosity_level from ..config import load, mod_to_context, resource_keys +from click.core import ParameterSource import time import click import logging @@ -388,6 +389,9 @@ class ResourceOption(click.Option): ) logger.debug("consuming resource option for %s", self.name) value = opts.get(self.name) + + source = ParameterSource.COMMANDLINE + # if value is not given from command line, lookup the config files given as # arguments (not options). if value is None: @@ -399,13 +403,21 @@ class ResourceOption(click.Option): # if not from config files, lookup the environment variables if value is None: value = self.value_from_envvar(ctx) + source = ParameterSource.ENVIRONMENT + # if not from environment variables, lookup the default value if value is None: value = ctx.lookup_default(self.name) - return value + source = ParameterSource.DEFAULT_MAP - def full_process_value(self, ctx, value): - value = super().full_process_value(ctx, value) + if value is None: + value = self.get_default(ctx) + source = ParameterSource.DEFAULT + + return value, source + + def type_cast_value(self, ctx, value): + value = super().type_cast_value(ctx, value) # if the value is a string and an entry_point_group is provided, load it if self.entry_point_group is not None: @@ -415,6 +427,7 @@ class ResourceOption(click.Option): entry_point_group=self.entry_point_group, attribute_name=self.name, ) + return value diff --git a/conda/meta.yaml b/conda/meta.yaml index efffeb8141995947cc746da2da6441056de36892..be3d13c71ac1db17ac66845dbccbec6902cae430 100644 --- a/conda/meta.yaml +++ b/conda/meta.yaml @@ -20,6 +20,7 @@ requirements: host: - python {{ python }} - setuptools {{ setuptools }} + - click >=8 - click {{ click }} - click-plugins {{ click_plugins }} run: diff --git a/setup.py b/setup.py index b20fb58440e31ca6ac6c8199460f7ccbc3d33c22..d2c8869c12fabf6e002d74f2d687b797b4602a5b 100644 --- a/setup.py +++ b/setup.py @@ -22,7 +22,7 @@ setup( include_package_data=True, zip_safe=False, - install_requires=['setuptools', 'click', 'click-plugins'], + install_requires=['setuptools', 'click >= 8', 'click-plugins'], entry_points={ 'console_scripts': [