Skip to content
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

Merged
merged 5 commits into from Jul 5, 2016
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion easybuild/framework/easyconfig/tools.py
Expand Up @@ -188,7 +188,7 @@ def mk_node_name(spec):
all_nodes.add(spec['module'])
spec['ec'].all_dependencies = [mk_node_name(s) for s in spec['ec'].all_dependencies]
all_nodes.update(spec['ec'].all_dependencies)

# Get the build dependencies for each spec so we can distinguish them later
spec['ec'].build_dependencies = [mk_node_name(s) for s in spec['ec']['builddependencies']]
all_nodes.update(spec['ec'].build_dependencies)
Expand Down
45 changes: 44 additions & 1 deletion easybuild/tools/docs.py
Expand Up @@ -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


Expand Down Expand Up @@ -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
Copy link
Member

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)

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()],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

two more problems here: sorting, and you have no strict guarantee that .values() will return things in the same key-order when being called twice

so, collect .items() before, and sort by key, then build up table_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 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
Expand Down
9 changes: 7 additions & 2 deletions easybuild/tools/options.py
Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line is getting too long, move some of the avail ones to the line above

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
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down