def test_topo_sort_filtered(mock_packages): """Test topo sort gives correct order when filtering link deps.""" s = Spec('both-link-and-build-dep-a').normalized() topo = topological_sort(s, deptype=('link',)) assert topo == ['both-link-and-build-dep-a', 'both-link-and-build-dep-c']
def deactivate(parser, args): specs = spack.cmd.parse_specs(args.spec) if len(specs) != 1: tty.die("deactivate requires one spec. %d given." % len(specs)) spec = spack.cmd.disambiguate_spec(specs[0]) pkg = spec.package if args.view: target = args.view elif pkg.is_extension: target = pkg.extendee_spec.prefix elif pkg.extendable: target = spec.prefix view = YamlFilesystemView(target, spack.store.layout) if args.all: if pkg.extendable: tty.msg("Deactivating all extensions of %s" % pkg.spec.short_spec) ext_pkgs = spack.store.db.activated_extensions_for( spec, view.extensions_layout) for ext_pkg in ext_pkgs: ext_pkg.spec.normalize() if ext_pkg.is_activated(view): ext_pkg.do_deactivate(view, force=True) elif pkg.is_extension: if not args.force and \ not spec.package.is_activated(view): tty.die("%s is not activated." % pkg.spec.short_spec) tty.msg("Deactivating %s and all dependencies." % pkg.spec.short_spec) topo_order = topological_sort(spec) index = spec.index() for name in topo_order: espec = index[name] epkg = espec.package if epkg.extends(pkg.extendee_spec): if epkg.is_activated(view) or args.force: epkg.do_deactivate(view, force=args.force) else: tty.die("spack deactivate --all requires an extendable package " "or an extension.") else: if not pkg.is_extension: tty.die("spack deactivate requires an extension.", "Did you mean 'spack deactivate --all'?") if not args.force and \ not spec.package.is_activated(view): tty.die("Package %s is not activated." % specs[0].short_spec) spec.package.do_deactivate(view, force=args.force)
def deactivate(parser, args): # TODO: shouldn't have to concretize here. Fix DAG issues. specs = spack.cmd.parse_specs(args.spec, concretize=True) if len(specs) != 1: tty.die("deactivate requires one spec. %d given." % len(specs)) # TODO: remove this hack when DAG info is stored properly. # This ensures the ext spec is always normalized properly. spack.db.get(specs[0]) spec = spack.cmd.disambiguate_spec(specs[0]) pkg = spec.package if args.all: if pkg.extendable: tty.msg("Deactivating all extensions of %s" % pkg.spec.short_spec) ext_pkgs = spack.db.installed_extensions_for(spec) for ext_pkg in ext_pkgs: ext_pkg.spec.normalize() if ext_pkg.activated: ext_pkg.do_deactivate(force=True) elif pkg.is_extension: # TODO: store DAG info properly (see above) spec.normalize() if not args.force and not spec.package.activated: tty.die("%s is not activated." % pkg.spec.short_spec) tty.msg("Deactivating %s and all dependencies." % pkg.spec.short_spec) topo_order = topological_sort(spec) index = spec.index() for name in topo_order: espec = index[name] epkg = espec.package # TODO: store DAG info properly (see above) epkg.spec.normalize() if epkg.extends(pkg.extendee_spec): if epkg.activated or args.force: epkg.do_deactivate(force=args.force) else: tty.die("spack deactivate --all requires an extendable package or an extension.") else: if not pkg.is_extension: tty.die("spack deactivate requires an extension.", "Did you mean 'spack deactivate --all'?") if not args.force and not spec.package.activated: tty.die("Package %s is not activated." % specs[0].short_spec) spec.package.do_deactivate(force=args.force)
def deactivate(parser, args): specs = spack.cmd.parse_specs(args.spec) if len(specs) != 1: tty.die("deactivate requires one spec. %d given." % len(specs)) spec = spack.cmd.disambiguate_spec(specs[0]) pkg = spec.package if args.all: if pkg.extendable: tty.msg("Deactivating all extensions of %s" % pkg.spec.short_spec) ext_pkgs = spack.store.db.installed_extensions_for(spec) for ext_pkg in ext_pkgs: ext_pkg.spec.normalize() if ext_pkg.activated: ext_pkg.do_deactivate(force=True) elif pkg.is_extension: if not args.force and not spec.package.activated: tty.die("%s is not activated." % pkg.spec.short_spec) tty.msg("Deactivating %s and all dependencies." % pkg.spec.short_spec) topo_order = topological_sort(spec) index = spec.index() for name in topo_order: espec = index[name] epkg = espec.package if epkg.extends(pkg.extendee_spec): if epkg.activated or args.force: epkg.do_deactivate(force=args.force) else: tty.die( "spack deactivate --all requires an extendable package " "or an extension.") else: if not pkg.is_extension: tty.die("spack deactivate requires an extension.", "Did you mean 'spack deactivate --all'?") if not args.force and not spec.package.activated: tty.die("Package %s is not activated." % specs[0].short_spec) spec.package.do_deactivate(force=args.force)
def deactivate(parser, args): specs = spack.cmd.parse_specs(args.spec) if len(specs) != 1: tty.die("deactivate requires one spec. %d given." % len(specs)) spec = spack.cmd.disambiguate_spec(specs[0]) pkg = spec.package if args.all: if pkg.extendable: tty.msg("Deactivating all extensions of %s" % pkg.spec.short_spec) ext_pkgs = spack.installed_db.installed_extensions_for(spec) for ext_pkg in ext_pkgs: ext_pkg.spec.normalize() if ext_pkg.activated: ext_pkg.do_deactivate(force=True) elif pkg.is_extension: if not args.force and not spec.package.activated: tty.die("%s is not activated." % pkg.spec.short_spec) tty.msg("Deactivating %s and all dependencies." % pkg.spec.short_spec) topo_order = topological_sort(spec) index = spec.index() for name in topo_order: espec = index[name] epkg = espec.package if epkg.extends(pkg.extendee_spec): if epkg.activated or args.force: epkg.do_deactivate(force=args.force) else: tty.die( "spack deactivate --all requires an extendable package or an extension." ) else: if not pkg.is_extension: tty.die("spack deactivate requires an extension.", "Did you mean 'spack deactivate --all'?") if not args.force and not spec.package.activated: tty.die("Package %s is not activated." % specs[0].short_spec) spec.package.do_deactivate(force=args.force)
def test_topo_sort(mock_packages): """Test topo sort gives correct order.""" s = Spec('mpileaks').normalized() topo = topological_sort(s) assert topo.index('mpileaks') < topo.index('callpath') assert topo.index('mpileaks') < topo.index('mpi') assert topo.index('mpileaks') < topo.index('dyninst') assert topo.index('mpileaks') < topo.index('libdwarf') assert topo.index('mpileaks') < topo.index('libelf') assert topo.index('callpath') < topo.index('mpi') assert topo.index('callpath') < topo.index('dyninst') assert topo.index('callpath') < topo.index('libdwarf') assert topo.index('callpath') < topo.index('libelf') assert topo.index('dyninst') < topo.index('libdwarf') assert topo.index('dyninst') < topo.index('libelf') assert topo.index('libdwarf') < topo.index('libelf')