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 2 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,48 @@ def list_toolchains_txt(tcs): | |
return '\n'.join(doc) | ||
|
||
|
||
def avail_toolchain_opts(name, output_format=FORMAT_TXT): | ||
"""Show list of known toolchains.""" | ||
tc_class, _ = search_toolchain(name) | ||
if not tc_class: | ||
return "Couldn't find toolchain: '%s'. To see available toolchains, use --list-toolchains" % name | ||
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. please use |
||
tc = tc_class(version='1.0') | ||
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. add a comment to clarify that the version used here does not matter at all |
||
|
||
options = [tc.COMPILER_UNIQUE_OPTS, tc.COMPILER_SHARED_OPTS, tc.MPI_UNIQUE_OPTS, tc.MPI_SHARED_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. sort alphabetically |
||
|
||
tc_dict = {} | ||
for opt in options: | ||
if opt: # can be None | ||
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. check with |
||
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 all toolchains in rst format """ | ||
title = "Available options for %s toolchain:" % name | ||
|
||
table_titles = ['option', 'description', 'default'] | ||
|
||
table_values = [[] for i in range(len(table_titles))] | ||
table_values[0] = ['``%s``' % opt_name for opt_name in tc_dict.keys()] | ||
table_values[1] = ['%s' % val[1] for val in tc_dict.values()] | ||
table_values[2] = ['``%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. change to tables_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()],
] |
||
|
||
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 all toolchains 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,8 @@ 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)), | ||
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. make this a single line, it'll fit just fine 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. also, no need for the double |
||
'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 +604,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 +715,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(str(self.options.avail_toolchain_opts), self.options.output_format) | ||
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. why |
||
|
||
# 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 fix docstring