summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2015-03-12 23:50:07 -0700
committerTodd Gamblin <tgamblin@llnl.gov>2015-03-12 23:50:07 -0700
commitf97966d63a0b9d5dabe724c3dbfaaf8f3ebbfd59 (patch)
tree9095babdef9bbd5067bdab4321013c5d51b0a780
parent132aa690d80731147c701446b3de099d4647f4e9 (diff)
downloadspack-f97966d63a0b9d5dabe724c3dbfaaf8f3ebbfd59.tar.gz
spack-f97966d63a0b9d5dabe724c3dbfaaf8f3ebbfd59.tar.bz2
spack-f97966d63a0b9d5dabe724c3dbfaaf8f3ebbfd59.tar.xz
spack-f97966d63a0b9d5dabe724c3dbfaaf8f3ebbfd59.zip
SPACK-18: simpler build error messages
Suppress python stack trace on build error UNLESS in debug mode (spack -d). Now spack shows errors with a single red arrow, and it's easier to find the actual build output.
-rw-r--r--lib/spack/spack/package.py32
1 files changed, 24 insertions, 8 deletions
diff --git a/lib/spack/spack/package.py b/lib/spack/spack/package.py
index 75e6142a9d..36f1e8a777 100644
--- a/lib/spack/spack/package.py
+++ b/lib/spack/spack/package.py
@@ -62,6 +62,7 @@ from spack.version import *
from spack.stage import Stage
from spack.util.web import get_pages
from spack.util.compression import allowed_archive, extension
+from spack.util.executable import ProcessError
"""Allowed URL schemes for spack packages."""
_ALLOWED_URL_SCHEMES = ["http", "https", "ftp", "file", "git"]
@@ -805,6 +806,16 @@ class Package(object):
# package naming scheme it likes.
spack.install_layout.make_path_for_spec(self.spec)
+ def cleanup():
+ if not keep_prefix:
+ # If anything goes wrong, remove the install prefix
+ self.remove_prefix()
+ else:
+ tty.warn("Keeping install prefix in place despite error.",
+ "Spack will think this package is installed." +
+ "Manually remove this directory to fix:",
+ self.prefix)
+
def real_work():
try:
tty.msg("Building %s." % self.name)
@@ -837,15 +848,20 @@ class Package(object):
% (_hms(self._fetch_time), _hms(build_time), _hms(self._total_time)))
print_pkg(self.prefix)
- except:
- if not keep_prefix:
- # If anything goes wrong, remove the install prefix
- self.remove_prefix()
+ except ProcessError, e:
+ # One of the processes returned an error code.
+ # Suppress detailed stack trace here unless in debug mode
+ if spack.debug:
+ raise e
else:
- tty.warn("Keeping install prefix in place despite error.",
- "Spack will think this package is installed." +
- "Manually remove this directory to fix:",
- self.prefix)
+ tty.error(e)
+
+ # Still need to clean up b/c there was an error.
+ cleanup()
+
+ except:
+ # other exceptions just clean up and raise.
+ cleanup()
raise
build_env.fork(self, real_work)