diff options
author | Denis Davydov <davydden@gmail.com> | 2019-04-21 02:08:05 +0500 |
---|---|---|
committer | Peter Scheibel <scheibel1@llnl.gov> | 2019-04-20 14:08:05 -0700 |
commit | 95fafb4e44d92c341cc4c2f07cea93b1077f0a92 (patch) | |
tree | 538e6a1344f27e5d31dad3bd73d91c70b783344b /lib | |
parent | 39855fbcf8316813c786af158d017d6fb42acadf (diff) | |
download | spack-95fafb4e44d92c341cc4c2f07cea93b1077f0a92.tar.gz spack-95fafb4e44d92c341cc4c2f07cea93b1077f0a92.tar.bz2 spack-95fafb4e44d92c341cc4c2f07cea93b1077f0a92.tar.xz spack-95fafb4e44d92c341cc4c2f07cea93b1077f0a92.zip |
Move NoLibrariesError/NoHeadersError into error.py (#10997)
Also add constructor to NoLibrariesError which can either take an
error message (like other SpackErrors) or a name and prefix (in
which case the error message is constructed).
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/build_environment.py | 5 | ||||
-rw-r--r-- | lib/spack/spack/error.py | 15 | ||||
-rw-r--r-- | lib/spack/spack/spec.py | 11 |
3 files changed, 20 insertions, 11 deletions
diff --git a/lib/spack/spack/build_environment.py b/lib/spack/spack/build_environment.py index 3d826937ba..90b02cc99f 100644 --- a/lib/spack/spack/build_environment.py +++ b/lib/spack/spack/build_environment.py @@ -58,6 +58,7 @@ from spack.util.environment import ( env_flag, filter_system_paths, get_path, is_system_path, EnvironmentModifications, validate, preserve_environment) from spack.util.environment import system_dirs +from spack.error import NoLibrariesError, NoHeadersError from spack.util.executable import Executable from spack.util.module_cmd import load_module, get_path_from_module from spack.util.log_parse import parse_log_events, make_log_context @@ -280,7 +281,7 @@ def set_build_environment_variables(pkg, env, dirty): dep_link_dirs = list() try: dep_link_dirs.extend(query.libs.directories) - except spack.spec.NoLibrariesError: + except NoLibrariesError: tty.debug("No libraries found for {0}".format(dep.name)) for default_lib_dir in ['lib', 'lib64']: @@ -294,7 +295,7 @@ def set_build_environment_variables(pkg, env, dirty): try: include_dirs.extend(query.headers.directories) - except spack.spec.NoHeadersError: + except NoHeadersError: tty.debug("No headers found for {0}".format(dep.name)) link_dirs = list(dedupe(filter_system_paths(link_dirs))) diff --git a/lib/spack/spack/error.py b/lib/spack/spack/error.py index 0adddb432a..81968ac569 100644 --- a/lib/spack/spack/error.py +++ b/lib/spack/spack/error.py @@ -98,6 +98,21 @@ class UnsupportedPlatformError(SpackError): super(UnsupportedPlatformError, self).__init__(message) +class NoLibrariesError(SpackError): + """Raised when package libraries are requested but cannot be found""" + + def __init__(self, message_or_name, prefix=None): + super(NoLibrariesError, self).__init__( + message_or_name if prefix is None else + 'Unable to locate {0} libraries in {1}'.format( + message_or_name, prefix) + ) + + +class NoHeadersError(SpackError): + """Raised when package headers are requested but cannot be found""" + + class SpecError(SpackError): """Superclass for all errors that occur while constructing specs.""" diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py index 6afdc92f24..0412465ba0 100644 --- a/lib/spack/spack/spec.py +++ b/lib/spack/spack/spec.py @@ -109,7 +109,8 @@ import spack.util.spack_yaml as syaml from spack.dependency import Dependency, all_deptypes, canonical_deptype from spack.util.module_cmd import get_path_from_module, load_module -from spack.error import SpackError, SpecError, UnsatisfiableSpecError +from spack.error import NoLibrariesError, NoHeadersError +from spack.error import SpecError, UnsatisfiableSpecError from spack.provider_index import ProviderIndex from spack.util.crypto import prefix_bits from spack.util.executable import Executable @@ -4019,14 +4020,6 @@ class DuplicateCompilerSpecError(SpecError): """Raised when the same compiler occurs in a spec twice.""" -class NoLibrariesError(SpackError): - """Raised when package libraries are requested but cannot be found""" - - -class NoHeadersError(SpackError): - """Raised when package headers are requested but cannot be found""" - - class UnsupportedCompilerError(SpecError): """Raised when the user asks for a compiler spack doesn't know about.""" def __init__(self, compiler_name): |