summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTodd Gamblin <gamblin2@llnl.gov>2021-08-03 03:00:33 -0700
committerGitHub <noreply@github.com>2021-08-03 10:00:33 +0000
commitfc840c904b4587a13199969ae5872581d5c33c32 (patch)
treed9dd2d8b7b55c30608f5b47ace89f5dc5681c16e /lib
parente47710134582d9ea67f12e46d2c43ecb21cfa2c4 (diff)
downloadspack-fc840c904b4587a13199969ae5872581d5c33c32.tar.gz
spack-fc840c904b4587a13199969ae5872581d5c33c32.tar.bz2
spack-fc840c904b4587a13199969ae5872581d5c33c32.tar.xz
spack-fc840c904b4587a13199969ae5872581d5c33c32.zip
executable: filter long paths from debug output (#25168)
Long, padded install paths can get to be very long in the verbose install output. This has to be filtered out by the Executable class, as it generates these debug messages. - [x] add ability to filter paths from Executable output. - [x] add a context manager that can enable path filtering - [x] make `build_process` in `installer.py` This should hopefully allow us to see most of the build output in Gitlab pipeline builds again.
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/installer.py6
-rw-r--r--lib/spack/spack/util/executable.py27
2 files changed, 31 insertions, 2 deletions
diff --git a/lib/spack/spack/installer.py b/lib/spack/spack/installer.py
index 68782a84bc..5ba5b3a70d 100644
--- a/lib/spack/spack/installer.py
+++ b/lib/spack/spack/installer.py
@@ -54,6 +54,7 @@ import spack.package
import spack.package_prefs as prefs
import spack.repo
import spack.store
+import spack.util.executable
from spack.util.environment import dump_environment
from spack.util.executable import which
from spack.util.timer import Timer
@@ -1883,7 +1884,10 @@ def build_process(pkg, install_args):
"""
installer = BuildProcessInstaller(pkg, install_args)
- return installer.run()
+
+ # don't print long padded paths in executable debug output.
+ with spack.util.executable.filter_padding():
+ return installer.run()
class BuildTask(object):
diff --git a/lib/spack/spack/util/executable.py b/lib/spack/spack/util/executable.py
index 1074a96cf7..94fc7f16a7 100644
--- a/lib/spack/spack/util/executable.py
+++ b/lib/spack/spack/util/executable.py
@@ -2,6 +2,7 @@
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+import contextlib
import os
import re
import shlex
@@ -16,6 +17,27 @@ import spack.error
__all__ = ['Executable', 'which', 'ProcessError']
+#: optionally filter padding on debug output in spack.util.executable
+_filter_padding = False
+
+
+@contextlib.contextmanager
+def filter_padding():
+ """Context manager to safely disable path padding in debug output.
+
+ This is needed because Spack's debug output gets extremely long when we use a
+ long padded installation path.
+ """
+ global _filter_padding
+ try:
+ # don't bother filtering if padding isn't actually enabled
+ padding = spack.config.get("config:install_tree:padded_length", None)
+ if padding:
+ _filter_padding = True
+ yield
+ finally:
+ _filter_padding = False
+
class Executable(object):
"""Class representing a program that can be run on the command line."""
@@ -187,7 +209,10 @@ class Executable(object):
cmd_line = "'%s'" % "' '".join(
map(lambda arg: arg.replace("'", "'\"'\"'"), cmd))
- tty.debug(cmd_line)
+ debug_cmd_line = cmd_line
+ if _filter_padding:
+ debug_cmd_line = [spack.util.path.padding_filter(elt) for elt in cmd_line]
+ tty.debug(debug_cmd_line)
try:
proc = subprocess.Popen(