From b5e136b729e3bde0b45ba2c0f189b6c4d13f0f85 Mon Sep 17 00:00:00 2001 From: Todd Gamblin Date: Thu, 12 Oct 2017 00:49:59 -0700 Subject: [PATCH] Better install output (#5714) * Do not call setup_package for fake installs - setup package could fail if ``setup_dependent_environment`` or other routines expected to use executables from dependencies - xpetsc and boost try to get python config variables in `setup_dependent_package`; this would cause them not to be fake-installable * Remove vestigial deptype_query argument to Spec.traverse() - The `deptype_query` argument isn't used anymore -- it's only passed around and causes confusion when calling traverse. - Get rid of it and just keep the `deptypes` argument * Don't print redundant messages when installing dependencies - `do_install()` was originally depth-first recursive, and printed " already installed in ..." multiple times for packages as recursive calls encountered them. - For much cleaner output, use spec.traverse(order='post') to install dependencies instead --- lib/spack/spack/build_environment.py | 6 ++++-- lib/spack/spack/cmd/buildcache.py | 3 +-- lib/spack/spack/cmd/fetch.py | 2 +- lib/spack/spack/cmd/mirror.py | 2 +- lib/spack/spack/package.py | 10 +++++----- lib/spack/spack/spec.py | 14 +++++--------- 6 files changed, 17 insertions(+), 20 deletions(-) diff --git a/lib/spack/spack/build_environment.py b/lib/spack/spack/build_environment.py index 9db4d4dd73..f7cee015b6 100644 --- a/lib/spack/spack/build_environment.py +++ b/lib/spack/spack/build_environment.py @@ -518,7 +518,7 @@ def setup_package(pkg, dirty): load_external_modules(pkg) -def fork(pkg, function, dirty): +def fork(pkg, function, dirty, fake): """Fork a child process to do part of a spack build. Args: @@ -529,6 +529,7 @@ def fork(pkg, function, dirty): process. dirty (bool): If True, do NOT clean the environment before building. + fake (bool): If True, skip package setup b/c it's not a real build Usage:: @@ -556,7 +557,8 @@ def child_process(child_pipe, input_stream): sys.stdin = input_stream try: - setup_package(pkg, dirty=dirty) + if not fake: + setup_package(pkg, dirty=dirty) return_value = function() child_pipe.send(return_value) except StopIteration as e: diff --git a/lib/spack/spack/cmd/buildcache.py b/lib/spack/spack/cmd/buildcache.py index 71386a221c..cbcaafe81b 100644 --- a/lib/spack/spack/cmd/buildcache.py +++ b/lib/spack/spack/cmd/buildcache.py @@ -118,8 +118,7 @@ def createtarball(args): tty.msg('recursing dependencies') for d, node in spec.traverse(order='post', depth=True, - deptype=('link', 'run'), - deptype_query='run'): + deptype=('link', 'run')): if not node.external: tty.msg('adding dependency %s' % node.format()) specs.add(node) diff --git a/lib/spack/spack/cmd/fetch.py b/lib/spack/spack/cmd/fetch.py index 52caf7e80d..9df5f81404 100644 --- a/lib/spack/spack/cmd/fetch.py +++ b/lib/spack/spack/cmd/fetch.py @@ -57,7 +57,7 @@ def fetch(parser, args): specs = spack.cmd.parse_specs(args.packages, concretize=True) for spec in specs: if args.missing or args.dependencies: - for s in spec.traverse(deptype_query=all): + for s in spec.traverse(): package = spack.repo.get(s) if args.missing and package.installed: continue diff --git a/lib/spack/spack/cmd/mirror.py b/lib/spack/spack/cmd/mirror.py index a24cf6b25d..60dd372432 100644 --- a/lib/spack/spack/cmd/mirror.py +++ b/lib/spack/spack/cmd/mirror.py @@ -182,7 +182,7 @@ def mirror_create(args): new_specs = set() for spec in specs: spec.concretize() - for s in spec.traverse(deptype_query=all): + for s in spec.traverse(): new_specs.add(s) specs = list(new_specs) diff --git a/lib/spack/spack/package.py b/lib/spack/spack/package.py index 57653d7d8b..4bcfa9703e 100644 --- a/lib/spack/spack/package.py +++ b/lib/spack/spack/package.py @@ -1320,19 +1320,19 @@ def do_install(self, # First, install dependencies recursively. if install_deps: tty.debug('Installing {0} dependencies'.format(self.name)) - for dep in self.spec.dependencies(): + for dep in self.spec.traverse(order='post', root=False): dep.package.do_install( + install_deps=False, + explicit=False, keep_prefix=keep_prefix, keep_stage=keep_stage, install_source=install_source, - install_deps=install_deps, fake=fake, skip_patch=skip_patch, verbose=verbose, make_jobs=make_jobs, dirty=dirty, - **kwargs - ) + **kwargs) tty.msg('Installing %s' % self.name) @@ -1428,7 +1428,7 @@ def build_process(): # Fork a child to do the actual installation # we preserve verbosity settings across installs. PackageBase._verbose = spack.build_environment.fork( - self, build_process, dirty=dirty) + self, build_process, dirty=dirty, fake=fake) # If we installed then we should keep the prefix keep_prefix = self.last_phase is None or keep_prefix diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py index ea00e1723d..4ae7a1a5b4 100644 --- a/lib/spack/spack/spec.py +++ b/lib/spack/spack/spec.py @@ -1250,7 +1250,7 @@ def traverse(self, **kwargs): yield get_spec(dspec) def traverse_edges(self, visited=None, d=0, deptype='all', - deptype_query=default_deptype, dep_spec=None, **kwargs): + dep_spec=None, **kwargs): """Generic traversal of the DAG represented by this spec. This will yield each node in the spec. Options: @@ -1301,9 +1301,7 @@ def traverse_edges(self, visited=None, d=0, deptype='all', cover = kwargs.get('cover', 'nodes') direction = kwargs.get('direction', 'children') order = kwargs.get('order', 'pre') - deptype = canonical_deptype(deptype) - deptype_query = canonical_deptype(deptype_query) # Make sure kwargs have legal values; raise ValueError if not. def validate(name, val, allowed_values): @@ -1356,7 +1354,6 @@ def return_val(dspec): visited, d=(d + 1), deptype=deptype, - deptype_query=deptype_query, dep_spec=dspec, **kwargs) for elt in children: @@ -1797,7 +1794,7 @@ def concretize(self): changed = any(changes) force = True - for s in self.traverse(deptype_query=all): + for s in self.traverse(): # After concretizing, assign namespaces to anything left. # Note that this doesn't count as a "change". The repository # configuration is constant throughout a spack run, and @@ -1887,7 +1884,7 @@ def _mark_concrete(self, value=True): Only for internal use -- client code should use "concretize" unless there is a need to force a spec to be concrete. """ - for s in self.traverse(deptype_query=all): + for s in self.traverse(): if (not value) and s.concrete and s.package.installed: continue s._normal = value @@ -1912,11 +1909,10 @@ def flat_dependencies(self, **kwargs): returns them. """ copy = kwargs.get('copy', True) - deptype_query = kwargs.get('deptype_query', 'all') flat_deps = {} try: - deptree = self.traverse(root=False, deptype_query=deptype_query) + deptree = self.traverse(root=False) for spec in deptree: if spec.name not in flat_deps: @@ -2175,7 +2171,7 @@ def normalize(self, force=False): # Ensure first that all packages & compilers in the DAG exist. self.validate_or_raise() # Get all the dependencies into one DependencyMap - spec_deps = self.flat_dependencies(copy=False, deptype_query=all) + spec_deps = self.flat_dependencies(copy=False) # Initialize index of virtual dependency providers if # concretize didn't pass us one already