Improve reporting when bootstrapping from source
Signed-off-by: Massimiliano Culpo <massimiliano.culpo@gmail.com>
This commit is contained in:
parent
058e19458d
commit
da06ad3303
@ -996,11 +996,8 @@ def _receive_forwarded(self, context: str, exc: Exception, tb: List[str]):
|
|||||||
def grouped_message(self, with_tracebacks: bool = True) -> str:
|
def grouped_message(self, with_tracebacks: bool = True) -> str:
|
||||||
"""Print out an error message coalescing all the forwarded errors."""
|
"""Print out an error message coalescing all the forwarded errors."""
|
||||||
each_exception_message = [
|
each_exception_message = [
|
||||||
"{0} raised {1}: {2}{3}".format(
|
"\n\t{0} raised {1}: {2}\n{3}".format(
|
||||||
context,
|
context, exc.__class__.__name__, exc, f"\n{''.join(tb)}" if with_tracebacks else ""
|
||||||
exc.__class__.__name__,
|
|
||||||
exc,
|
|
||||||
"\n{0}".format("".join(tb)) if with_tracebacks else "",
|
|
||||||
)
|
)
|
||||||
for context, exc, tb in self.exceptions
|
for context, exc, tb in self.exceptions
|
||||||
]
|
]
|
||||||
|
@ -62,9 +62,15 @@ def _valid_compiler_or_raise(self):
|
|||||||
)
|
)
|
||||||
candidates.sort(key=lambda x: x.version, reverse=True)
|
candidates.sort(key=lambda x: x.version, reverse=True)
|
||||||
best = candidates[0]
|
best = candidates[0]
|
||||||
# FIXME (compiler as nodes): we need to find a better place for setting namespaces
|
# Get compilers for bootstrapping from the 'builtin' repository
|
||||||
best.namespace = "builtin"
|
best.namespace = "builtin"
|
||||||
# TODO: check it has C and C++, and supports C++14
|
# If the compiler does not support C++ 14, fail with a legible error message
|
||||||
|
try:
|
||||||
|
_ = best.package.standard_flag(language="cxx", standard="14")
|
||||||
|
except RuntimeError as e:
|
||||||
|
raise RuntimeError(
|
||||||
|
"cannot find a compiler supporting C++ 14 [needed to bootstrap clingo]"
|
||||||
|
) from e
|
||||||
return candidates[0]
|
return candidates[0]
|
||||||
|
|
||||||
def _externals_from_yaml(
|
def _externals_from_yaml(
|
||||||
|
@ -321,11 +321,10 @@ def create_bootstrapper(conf: ConfigDictionary):
|
|||||||
return _bootstrap_methods[btype](conf)
|
return _bootstrap_methods[btype](conf)
|
||||||
|
|
||||||
|
|
||||||
def source_is_enabled_or_raise(conf: ConfigDictionary):
|
def source_is_enabled(conf: ConfigDictionary):
|
||||||
"""Raise ValueError if the source is not enabled for bootstrapping"""
|
"""Raise ValueError if the source is not enabled for bootstrapping"""
|
||||||
trusted, name = spack.config.get("bootstrap:trusted"), conf["name"]
|
trusted, name = spack.config.get("bootstrap:trusted"), conf["name"]
|
||||||
if not trusted.get(name, False):
|
return trusted.get(name, False)
|
||||||
raise ValueError("source is not trusted")
|
|
||||||
|
|
||||||
|
|
||||||
def ensure_module_importable_or_raise(module: str, abstract_spec: Optional[str] = None):
|
def ensure_module_importable_or_raise(module: str, abstract_spec: Optional[str] = None):
|
||||||
@ -355,8 +354,10 @@ def ensure_module_importable_or_raise(module: str, abstract_spec: Optional[str]
|
|||||||
exception_handler = GroupedExceptionHandler()
|
exception_handler = GroupedExceptionHandler()
|
||||||
|
|
||||||
for current_config in bootstrapping_sources():
|
for current_config in bootstrapping_sources():
|
||||||
|
if not source_is_enabled(current_config):
|
||||||
|
continue
|
||||||
|
|
||||||
with exception_handler.forward(current_config["name"], Exception):
|
with exception_handler.forward(current_config["name"], Exception):
|
||||||
source_is_enabled_or_raise(current_config)
|
|
||||||
current_bootstrapper = create_bootstrapper(current_config)
|
current_bootstrapper = create_bootstrapper(current_config)
|
||||||
if current_bootstrapper.try_import(module, abstract_spec):
|
if current_bootstrapper.try_import(module, abstract_spec):
|
||||||
return
|
return
|
||||||
@ -368,11 +369,7 @@ def ensure_module_importable_or_raise(module: str, abstract_spec: Optional[str]
|
|||||||
msg = f'cannot bootstrap the "{module}" Python module '
|
msg = f'cannot bootstrap the "{module}" Python module '
|
||||||
if abstract_spec:
|
if abstract_spec:
|
||||||
msg += f'from spec "{abstract_spec}" '
|
msg += f'from spec "{abstract_spec}" '
|
||||||
if tty.is_debug():
|
msg += exception_handler.grouped_message(with_tracebacks=tty.is_debug())
|
||||||
msg += exception_handler.grouped_message(with_tracebacks=True)
|
|
||||||
else:
|
|
||||||
msg += exception_handler.grouped_message(with_tracebacks=False)
|
|
||||||
msg += "\nRun `spack --debug ...` for more detailed errors"
|
|
||||||
raise ImportError(msg)
|
raise ImportError(msg)
|
||||||
|
|
||||||
|
|
||||||
@ -410,8 +407,9 @@ def ensure_executables_in_path_or_raise(
|
|||||||
exception_handler = GroupedExceptionHandler()
|
exception_handler = GroupedExceptionHandler()
|
||||||
|
|
||||||
for current_config in bootstrapping_sources():
|
for current_config in bootstrapping_sources():
|
||||||
|
if not source_is_enabled(current_config):
|
||||||
|
continue
|
||||||
with exception_handler.forward(current_config["name"], Exception):
|
with exception_handler.forward(current_config["name"], Exception):
|
||||||
source_is_enabled_or_raise(current_config)
|
|
||||||
current_bootstrapper = create_bootstrapper(current_config)
|
current_bootstrapper = create_bootstrapper(current_config)
|
||||||
if current_bootstrapper.try_search_path(executables, abstract_spec):
|
if current_bootstrapper.try_search_path(executables, abstract_spec):
|
||||||
# Additional environment variables needed
|
# Additional environment variables needed
|
||||||
|
@ -5316,9 +5316,6 @@ class DuplicateCompilerSpecError(spack.error.SpecError):
|
|||||||
class UnsupportedCompilerError(spack.error.SpecError):
|
class UnsupportedCompilerError(spack.error.SpecError):
|
||||||
"""Raised when the user asks for a compiler spack doesn't know about."""
|
"""Raised when the user asks for a compiler spack doesn't know about."""
|
||||||
|
|
||||||
def __init__(self, compiler_name):
|
|
||||||
super().__init__("The '%s' compiler is not yet supported." % compiler_name)
|
|
||||||
|
|
||||||
|
|
||||||
class DuplicateArchitectureError(spack.error.SpecError):
|
class DuplicateArchitectureError(spack.error.SpecError):
|
||||||
"""Raised when the same architecture occurs in a spec twice."""
|
"""Raised when the same architecture occurs in a spec twice."""
|
||||||
|
Loading…
Reference in New Issue
Block a user