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 2 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
44 changes: 43 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,48 @@ def list_toolchains_txt(tcs):
return '\n'.join(doc)


def avail_toolchain_opts(name, output_format=FORMAT_TXT):
"""Show list of known toolchains."""
Copy link
Member

Choose a reason for hiding this comment

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

please fix docstring

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')
Copy link
Member

Choose a reason for hiding this comment

The 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]
Copy link
Member

Choose a reason for hiding this comment

The 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
Copy link
Member

Choose a reason for hiding this comment

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

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

Choose a reason for hiding this comment

The 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
Expand Down
10 changes: 8 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,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)),
Copy link
Member

Choose a reason for hiding this comment

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

make this a single line, it'll fit just fine

Copy link
Member

Choose a reason for hiding this comment

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

also, no need for the double (( and ))

'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 +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()
Expand Down Expand Up @@ -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)
Copy link
Member

Choose a reason for hiding this comment

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

why str(...)?


# dump known repository types
if self.options.avail_repositories:
msg += self.avail_repositories()
Expand Down