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 "<pkg>
  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
This commit is contained in:
Todd Gamblin 2017-10-12 00:49:59 -07:00 committed by GitHub
parent e807397074
commit b5e136b729
6 changed files with 17 additions and 20 deletions

View file

@ -518,7 +518,7 @@ def setup_package(pkg, dirty):
load_external_modules(pkg) 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. """Fork a child process to do part of a spack build.
Args: Args:
@ -529,6 +529,7 @@ def fork(pkg, function, dirty):
process. process.
dirty (bool): If True, do NOT clean the environment before dirty (bool): If True, do NOT clean the environment before
building. building.
fake (bool): If True, skip package setup b/c it's not a real build
Usage:: Usage::
@ -556,7 +557,8 @@ def child_process(child_pipe, input_stream):
sys.stdin = input_stream sys.stdin = input_stream
try: try:
setup_package(pkg, dirty=dirty) if not fake:
setup_package(pkg, dirty=dirty)
return_value = function() return_value = function()
child_pipe.send(return_value) child_pipe.send(return_value)
except StopIteration as e: except StopIteration as e:

View file

@ -118,8 +118,7 @@ def createtarball(args):
tty.msg('recursing dependencies') tty.msg('recursing dependencies')
for d, node in spec.traverse(order='post', for d, node in spec.traverse(order='post',
depth=True, depth=True,
deptype=('link', 'run'), deptype=('link', 'run')):
deptype_query='run'):
if not node.external: if not node.external:
tty.msg('adding dependency %s' % node.format()) tty.msg('adding dependency %s' % node.format())
specs.add(node) specs.add(node)

View file

@ -57,7 +57,7 @@ def fetch(parser, args):
specs = spack.cmd.parse_specs(args.packages, concretize=True) specs = spack.cmd.parse_specs(args.packages, concretize=True)
for spec in specs: for spec in specs:
if args.missing or args.dependencies: if args.missing or args.dependencies:
for s in spec.traverse(deptype_query=all): for s in spec.traverse():
package = spack.repo.get(s) package = spack.repo.get(s)
if args.missing and package.installed: if args.missing and package.installed:
continue continue

View file

@ -182,7 +182,7 @@ def mirror_create(args):
new_specs = set() new_specs = set()
for spec in specs: for spec in specs:
spec.concretize() spec.concretize()
for s in spec.traverse(deptype_query=all): for s in spec.traverse():
new_specs.add(s) new_specs.add(s)
specs = list(new_specs) specs = list(new_specs)

View file

@ -1320,19 +1320,19 @@ def do_install(self,
# First, install dependencies recursively. # First, install dependencies recursively.
if install_deps: if install_deps:
tty.debug('Installing {0} dependencies'.format(self.name)) 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( dep.package.do_install(
install_deps=False,
explicit=False,
keep_prefix=keep_prefix, keep_prefix=keep_prefix,
keep_stage=keep_stage, keep_stage=keep_stage,
install_source=install_source, install_source=install_source,
install_deps=install_deps,
fake=fake, fake=fake,
skip_patch=skip_patch, skip_patch=skip_patch,
verbose=verbose, verbose=verbose,
make_jobs=make_jobs, make_jobs=make_jobs,
dirty=dirty, dirty=dirty,
**kwargs **kwargs)
)
tty.msg('Installing %s' % self.name) tty.msg('Installing %s' % self.name)
@ -1428,7 +1428,7 @@ def build_process():
# Fork a child to do the actual installation # Fork a child to do the actual installation
# we preserve verbosity settings across installs. # we preserve verbosity settings across installs.
PackageBase._verbose = spack.build_environment.fork( 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 # If we installed then we should keep the prefix
keep_prefix = self.last_phase is None or keep_prefix keep_prefix = self.last_phase is None or keep_prefix

View file

@ -1250,7 +1250,7 @@ def traverse(self, **kwargs):
yield get_spec(dspec) yield get_spec(dspec)
def traverse_edges(self, visited=None, d=0, deptype='all', 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. """Generic traversal of the DAG represented by this spec.
This will yield each node in the spec. Options: 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') cover = kwargs.get('cover', 'nodes')
direction = kwargs.get('direction', 'children') direction = kwargs.get('direction', 'children')
order = kwargs.get('order', 'pre') order = kwargs.get('order', 'pre')
deptype = canonical_deptype(deptype) deptype = canonical_deptype(deptype)
deptype_query = canonical_deptype(deptype_query)
# Make sure kwargs have legal values; raise ValueError if not. # Make sure kwargs have legal values; raise ValueError if not.
def validate(name, val, allowed_values): def validate(name, val, allowed_values):
@ -1356,7 +1354,6 @@ def return_val(dspec):
visited, visited,
d=(d + 1), d=(d + 1),
deptype=deptype, deptype=deptype,
deptype_query=deptype_query,
dep_spec=dspec, dep_spec=dspec,
**kwargs) **kwargs)
for elt in children: for elt in children:
@ -1797,7 +1794,7 @@ def concretize(self):
changed = any(changes) changed = any(changes)
force = True force = True
for s in self.traverse(deptype_query=all): for s in self.traverse():
# After concretizing, assign namespaces to anything left. # After concretizing, assign namespaces to anything left.
# Note that this doesn't count as a "change". The repository # Note that this doesn't count as a "change". The repository
# configuration is constant throughout a spack run, and # 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" Only for internal use -- client code should use "concretize"
unless there is a need to force a spec to be concrete. 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: if (not value) and s.concrete and s.package.installed:
continue continue
s._normal = value s._normal = value
@ -1912,11 +1909,10 @@ def flat_dependencies(self, **kwargs):
returns them. returns them.
""" """
copy = kwargs.get('copy', True) copy = kwargs.get('copy', True)
deptype_query = kwargs.get('deptype_query', 'all')
flat_deps = {} flat_deps = {}
try: try:
deptree = self.traverse(root=False, deptype_query=deptype_query) deptree = self.traverse(root=False)
for spec in deptree: for spec in deptree:
if spec.name not in flat_deps: 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. # Ensure first that all packages & compilers in the DAG exist.
self.validate_or_raise() self.validate_or_raise()
# Get all the dependencies into one DependencyMap # 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 # Initialize index of virtual dependency providers if
# concretize didn't pass us one already # concretize didn't pass us one already