bootstrapping: improve error messages (#26399)

This commit is contained in:
Harmen Stoppels 2021-10-01 13:00:14 +02:00 committed by GitHub
parent 6ca42f0199
commit 5b9f60f9bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 8 deletions

View File

@ -216,6 +216,10 @@ def try_import(self, module, abstract_spec_str):
# specs that wwe know by dag hash. # specs that wwe know by dag hash.
spack.binary_distribution.binary_index.regenerate_spec_cache() spack.binary_distribution.binary_index.regenerate_spec_cache()
index = spack.binary_distribution.update_cache_and_get_specs() index = spack.binary_distribution.update_cache_and_get_specs()
if not index:
raise RuntimeError("Could not populate the binary index")
for item in data['verified']: for item in data['verified']:
candidate_spec = item['spec'] candidate_spec = item['spec']
python_spec = item['python'] python_spec = item['python']
@ -273,6 +277,8 @@ def try_import(module, abstract_spec_str):
if _try_import_from_store(module, abstract_spec_str): if _try_import_from_store(module, abstract_spec_str):
return True return True
tty.info("Bootstrapping {0} from sources".format(module))
# Try to build and install from sources # Try to build and install from sources
with spack_python_interpreter(): with spack_python_interpreter():
# Add hint to use frontend operating system on Cray # Add hint to use frontend operating system on Cray
@ -285,16 +291,15 @@ def try_import(module, abstract_spec_str):
if module == 'clingo': if module == 'clingo':
# TODO: remove when the old concretizer is deprecated # TODO: remove when the old concretizer is deprecated
concrete_spec._old_concretize() concrete_spec._old_concretize(deprecation_warning=False)
else: else:
concrete_spec.concretize() concrete_spec.concretize()
msg = "[BOOTSTRAP MODULE {0}] Try installing '{1}' from sources" msg = "[BOOTSTRAP MODULE {0}] Try installing '{1}' from sources"
tty.debug(msg.format(module, abstract_spec_str)) tty.debug(msg.format(module, abstract_spec_str))
tty.info("Bootstrapping {0} from sources".format(module))
# Install the spec that should make the module importable # Install the spec that should make the module importable
concrete_spec.package.do_install() concrete_spec.package.do_install(fail_fast=True)
return _try_import_from_store(module, abstract_spec_str=abstract_spec_str) return _try_import_from_store(module, abstract_spec_str=abstract_spec_str)
@ -377,6 +382,9 @@ def ensure_module_importable_or_raise(module, abstract_spec=None):
abstract_spec = abstract_spec or module abstract_spec = abstract_spec or module
source_configs = spack.config.get('bootstrap:sources', []) source_configs = spack.config.get('bootstrap:sources', [])
errors = {}
for current_config in source_configs: for current_config in source_configs:
if not _source_is_trusted(current_config): if not _source_is_trusted(current_config):
msg = ('[BOOTSTRAP MODULE {0}] Skipping source "{1}" since it is ' msg = ('[BOOTSTRAP MODULE {0}] Skipping source "{1}" since it is '
@ -391,11 +399,18 @@ def ensure_module_importable_or_raise(module, abstract_spec=None):
except Exception as e: except Exception as e:
msg = '[BOOTSTRAP MODULE {0}] Unexpected error "{1}"' msg = '[BOOTSTRAP MODULE {0}] Unexpected error "{1}"'
tty.debug(msg.format(module, str(e))) tty.debug(msg.format(module, str(e)))
errors[current_config['name']] = e
# We couldn't import in any way, so raise an import error # We couldn't import in any way, so raise an import error
msg = 'cannot bootstrap the "{0}" Python module'.format(module) msg = 'cannot bootstrap the "{0}" Python module'.format(module)
if abstract_spec: if abstract_spec:
msg += ' from spec "{0}"'.format(abstract_spec) msg += ' from spec "{0}"'.format(abstract_spec)
msg += ' due to the following failures:\n'
for method in errors:
err = errors[method]
msg += " '{0}' raised {1}: {2}\n".format(
method, err.__class__.__name__, str(err))
msg += ' Please run `spack -d spec zlib` for more verbose error messages'
raise ImportError(msg) raise ImportError(msg)

View File

@ -2357,13 +2357,15 @@ def feq(cfield, sfield):
return changed return changed
def _old_concretize(self, tests=False): def _old_concretize(self, tests=False, deprecation_warning=True):
"""A spec is concrete if it describes one build of a package uniquely. """A spec is concrete if it describes one build of a package uniquely.
This will ensure that this spec is concrete. This will ensure that this spec is concrete.
Args: Args:
tests (list or bool): list of packages that will need test tests (list or bool): list of packages that will need test
dependencies, or True/False for test all/none dependencies, or True/False for test all/none
deprecation_warning (bool): enable or disable the deprecation
warning for the old concretizer
If this spec could describe more than one version, variant, or build If this spec could describe more than one version, variant, or build
of a package, this will add constraints to make it concrete. of a package, this will add constraints to make it concrete.
@ -2377,6 +2379,7 @@ def _old_concretize(self, tests=False):
# Add a warning message to inform users that the original concretizer # Add a warning message to inform users that the original concretizer
# will be removed in v0.18.0 # will be removed in v0.18.0
if deprecation_warning:
msg = ('the original concretizer is currently being used.\n\tUpgrade to ' msg = ('the original concretizer is currently being used.\n\tUpgrade to '
'"clingo" at your earliest convenience. The original concretizer ' '"clingo" at your earliest convenience. The original concretizer '
'will be removed from Spack starting at v0.18.0') 'will be removed from Spack starting at v0.18.0')