Skip to content

Commit

Permalink
add support for alternative EasyBuild configuration options (WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
boegel committed Jun 10, 2024
1 parent 4223ede commit 99ff5d6
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion easybuild/tools/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@ def terminal_supports_colors(stream):
return False


# alternative names for EasyBuild configuration options;
# format: '<new-and-better-name>': '<old-and-soon-to-be-deprecated-name>'
ALTERNATIVE_EASYBUILD_CONFIGURATION_OPTIONS = {
'build-path': 'buildpath',
}

CONFIG_ENV_VAR_PREFIX = 'EASYBUILD'

XDG_CONFIG_HOME = os.environ.get('XDG_CONFIG_HOME', os.path.join(os.path.expanduser('~'), ".config"))
Expand Down Expand Up @@ -207,6 +213,18 @@ def use_color(colorize, stream=sys.stdout):
return False


def add_alternate_options(opts):
"""
Add alternative names to provided dictionary of configuration options
"""
rev_map_alt_cfg_opts = {v: k for k, v in ALTERNATIVE_EASYBUILD_CONFIGURATION_OPTIONS.items()}
for key in rev_map_alt_cfg_opts:
if key in opts:
alt_key = rev_map_alt_cfg_opts[key]
alt_descr = opts[key][0] + f" (alternative for --{key})"
opts[alt_key] = (alt_descr,) + opts[key][1:]


class EasyBuildOptions(GeneralOption):
"""Easybuild generaloption class"""
VERSION = this_is_easybuild()
Expand Down Expand Up @@ -550,7 +568,7 @@ def config_options(self):
None, "store_true", False,),
'avail-repositories': ("Show all repository types (incl. non-usable)",
None, "store_true", False,),
'buildpath': ("Temporary build path", None, 'store', mk_full_default_path('buildpath')),
'buildpath': ("Path for temporary build directories", None, 'store', mk_full_default_path('buildpath')),
'containerpath': ("Location where container recipe & image will be stored", None, 'store',
mk_full_default_path('containerpath')),
'envvars-user-modules': ("List of environment variables that hold the base paths for which user-specific "
Expand Down Expand Up @@ -625,6 +643,8 @@ def config_options(self):
'tmpdir': ('Directory to use for temporary storage', None, 'store', None),
})

add_alternate_options(opts)

self.log.debug("config_options: descr %s opts %s" % (descr, opts))
self.add_group_parser(opts, descr)

Expand Down

0 comments on commit 99ff5d6

Please sign in to comment.