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.
This commit is contained in:
Todd Gamblin 2015-03-12 23:50:07 -07:00
parent 132aa690d8
commit f97966d63a

View File

@ -62,6 +62,7 @@
from spack.stage import Stage from spack.stage import Stage
from spack.util.web import get_pages from spack.util.web import get_pages
from spack.util.compression import allowed_archive, extension from spack.util.compression import allowed_archive, extension
from spack.util.executable import ProcessError
"""Allowed URL schemes for spack packages.""" """Allowed URL schemes for spack packages."""
_ALLOWED_URL_SCHEMES = ["http", "https", "ftp", "file", "git"] _ALLOWED_URL_SCHEMES = ["http", "https", "ftp", "file", "git"]
@ -805,6 +806,16 @@ def do_install(self, **kwargs):
# package naming scheme it likes. # package naming scheme it likes.
spack.install_layout.make_path_for_spec(self.spec) 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(): def real_work():
try: try:
tty.msg("Building %s." % self.name) tty.msg("Building %s." % self.name)
@ -837,15 +848,20 @@ def real_work():
% (_hms(self._fetch_time), _hms(build_time), _hms(self._total_time))) % (_hms(self._fetch_time), _hms(build_time), _hms(self._total_time)))
print_pkg(self.prefix) print_pkg(self.prefix)
except: except ProcessError, e:
if not keep_prefix: # One of the processes returned an error code.
# If anything goes wrong, remove the install prefix # Suppress detailed stack trace here unless in debug mode
self.remove_prefix() if spack.debug:
raise e
else: else:
tty.warn("Keeping install prefix in place despite error.", tty.error(e)
"Spack will think this package is installed." +
"Manually remove this directory to fix:", # Still need to clean up b/c there was an error.
self.prefix) cleanup()
except:
# other exceptions just clean up and raise.
cleanup()
raise raise
build_env.fork(self, real_work) build_env.fork(self, real_work)