New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add --avail-toolchain-opts #1830
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,7 +55,7 @@ | |
from easybuild.framework.extension import Extension | ||
from easybuild.tools.filetools import read_file | ||
from easybuild.tools.ordereddict import OrderedDict | ||
from easybuild.tools.toolchain.utilities import search_toolchain | ||
from easybuild.tools.toolchain.utilities import get_toolchain, search_toolchain | ||
from easybuild.tools.utilities import import_available_modules, quote_str | ||
|
||
|
||
|
@@ -556,6 +556,49 @@ def list_toolchains_txt(tcs): | |
return '\n'.join(doc) | ||
|
||
|
||
def avail_toolchain_opts(name, output_format=FORMAT_TXT): | ||
"""Show list of known options for given toolchain.""" | ||
tc_class, _ = search_toolchain(name) | ||
if not tc_class: | ||
return "Couldn't find toolchain: '%s'. To see available toolchains, use --list-toolchains" % name | ||
tc = tc_class(version='1.0') # version doesn't matter here, but needs to be defined | ||
|
||
options = [tc.COMPILER_SHARED_OPTS, tc.COMPILER_UNIQUE_OPTS, tc.MPI_SHARED_OPTS, tc.MPI_UNIQUE_OPTS] | ||
|
||
tc_dict = {} | ||
for opt in options: | ||
if opt is not None: | ||
tc_dict.update(opt) | ||
|
||
return generate_doc('avail_toolchain_opts_%s' % output_format, [name, tc_dict]) | ||
|
||
|
||
def avail_toolchain_opts_rst(name, tc_dict): | ||
""" Returns overview of toolchain options in rst format """ | ||
title = "Available options for %s toolchain:" % name | ||
|
||
table_titles = ['option', 'description', 'default'] | ||
|
||
table_values = [ | ||
['``%s``' % opt_name for opt_name in tc_dict.keys()], | ||
['%s' % val[1] for val in tc_dict.values()], | ||
['``%s``' % val[0] for val in tc_dict.values()], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. two more problems here: sorting, and you have no strict guarantee that so, collect |
||
] | ||
|
||
doc = rst_title_and_table(title, table_titles, table_values) | ||
|
||
return '\n'.join(doc) | ||
|
||
|
||
def avail_toolchain_opts_txt(name, tc_dict): | ||
""" Returns overview of toolchain options in txt format """ | ||
doc = ["Available options for %s toolchain:" % name] | ||
for opt_name in sorted(tc_dict.keys()): | ||
doc.append("%s%s: %s (default: %s)" % (INDENT_4SPACES, opt_name, tc_dict[opt_name][1], tc_dict[opt_name][0])) | ||
|
||
return '\n'.join(doc) | ||
|
||
|
||
def gen_easyblocks_overview_rst(package_name, path_to_examples, common_params={}, doc_functions=[]): | ||
""" | ||
Compose overview of all easyblocks in the given package in rst format | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,7 +57,7 @@ | |
from easybuild.tools.config import get_pretend_installpath, mk_full_default_path | ||
from easybuild.tools.configobj import ConfigObj, ConfigObjError | ||
from easybuild.tools.docs import FORMAT_TXT, FORMAT_RST | ||
from easybuild.tools.docs import avail_cfgfile_constants, avail_easyconfig_constants, avail_easyconfig_licenses | ||
from easybuild.tools.docs import avail_cfgfile_constants, avail_easyconfig_constants, avail_easyconfig_licenses, avail_toolchain_opts | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. line is getting too long, move some of the |
||
from easybuild.tools.docs import avail_easyconfig_params, avail_easyconfig_templates, list_easyblocks, list_toolchains | ||
from easybuild.tools.environment import restore_env, unset_env_vars | ||
from easybuild.tools.filetools import mkdir | ||
|
@@ -407,6 +407,7 @@ def informative_options(self): | |
'avail-easyconfig-templates': (("Show all template names and template constants " | ||
"that can be used in easyconfigs."), | ||
None, 'store_true', False), | ||
'avail-toolchain-opts': ("Show options for toolchain", 'str', 'store', None), | ||
'check-conflicts': ("Check for version conflicts in dependency graphs", None, 'store_true', False), | ||
'dep-graph': ("Create dependency graph", None, 'store', None, {'metavar': 'depgraph.<ext>'}), | ||
'dump-env-script': ("Dump source script to set up build environment based on toolchain/dependencies", | ||
|
@@ -602,7 +603,7 @@ def postprocess(self): | |
self.options.avail_easyconfig_constants, self.options.avail_easyconfig_licenses, | ||
self.options.avail_repositories, self.options.show_default_moduleclasses, | ||
self.options.avail_modules_tools, self.options.avail_module_naming_schemes, | ||
self.options.show_default_configfiles, | ||
self.options.show_default_configfiles, self.options.avail_toolchain_opts, | ||
]): | ||
build_easyconfig_constants_dict() # runs the easyconfig constants sanity check | ||
self._postprocess_list_avail() | ||
|
@@ -713,6 +714,10 @@ def _postprocess_list_avail(self): | |
if self.options.list_toolchains: | ||
msg += list_toolchains(self.options.output_format) | ||
|
||
# dump known toolchain options | ||
if self.options.avail_toolchain_opts: | ||
msg += avail_toolchain_opts(self.options.avail_toolchain_opts, self.options.output_format) | ||
|
||
# dump known repository types | ||
if self.options.avail_repositories: | ||
msg += self.avail_repositories() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use
raise EasyBuildError
here (which will print to stderr and exit)