summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2016-03-18 16:32:23 -0700
committerTodd Gamblin <tgamblin@llnl.gov>2016-03-18 16:32:23 -0700
commitc50d6ac9024fc74e5c8e784f9caf9d8950677991 (patch)
tree16f702326eed8b17c0b582b2f062db83eac818bb
parent741bea032c2d6e1dc8a4227c588743fb58008a1c (diff)
parente9126baaabbfaa5e12641b3d44a5c5fd49e43ca3 (diff)
downloadspack-c50d6ac9024fc74e5c8e784f9caf9d8950677991.tar.gz
spack-c50d6ac9024fc74e5c8e784f9caf9d8950677991.tar.bz2
spack-c50d6ac9024fc74e5c8e784f9caf9d8950677991.tar.xz
spack-c50d6ac9024fc74e5c8e784f9caf9d8950677991.zip
Merge pull request #578 from LLNL/features/gh-294-abort-build
Features/gh 294 abort build
-rw-r--r--lib/spack/docs/packaging_guide.rst14
-rw-r--r--lib/spack/spack/__init__.py8
-rw-r--r--lib/spack/spack/package.py4
3 files changed, 24 insertions, 2 deletions
diff --git a/lib/spack/docs/packaging_guide.rst b/lib/spack/docs/packaging_guide.rst
index c1077e4497..519c0da232 100644
--- a/lib/spack/docs/packaging_guide.rst
+++ b/lib/spack/docs/packaging_guide.rst
@@ -1844,6 +1844,20 @@ dedicated process.
.. _prefix-objects:
+
+Failing the build
+----------------------
+
+Sometimes you don't want a package to successfully install unless some
+condition is true. You can explicitly cause the build to fail from
+``install()`` by raising an ``InstallError``, for example:
+
+.. code-block:: python
+
+ if spec.architecture.startswith('darwin'):
+ raise InstallError('This package does not build on Mac OS X!')
+
+
Prefix objects
----------------------
diff --git a/lib/spack/spack/__init__.py b/lib/spack/spack/__init__.py
index 0ba42bbbfc..aee11f061f 100644
--- a/lib/spack/spack/__init__.py
+++ b/lib/spack/spack/__init__.py
@@ -189,5 +189,9 @@ import spack.util.executable
from spack.util.executable import *
__all__ += spack.util.executable.__all__
-from spack.package import install_dependency_symlinks, flatten_dependencies, DependencyConflictError
-__all__ += ['install_dependency_symlinks', 'flatten_dependencies', 'DependencyConflictError']
+from spack.package import \
+ install_dependency_symlinks, flatten_dependencies, DependencyConflictError, \
+ InstallError, ExternalPackageError
+__all__ += [
+ 'install_dependency_symlinks', 'flatten_dependencies', 'DependencyConflictError',
+ 'InstallError', 'ExternalPackageError']
diff --git a/lib/spack/spack/package.py b/lib/spack/spack/package.py
index b488e4c49d..dafad0b184 100644
--- a/lib/spack/spack/package.py
+++ b/lib/spack/spack/package.py
@@ -1351,6 +1351,10 @@ class InstallError(spack.error.SpackError):
super(InstallError, self).__init__(message, long_msg)
+class ExternalPackageError(InstallError):
+ """Raised by install() when a package is only for external use."""
+
+
class PackageStillNeededError(InstallError):
"""Raised when package is still needed by another on uninstall."""
def __init__(self, spec, dependents):