Exemplo n.º 1
0
def listspecs(args):
    """list binary packages available from mirrors"""
    specs = bindist.get_specs(args.force, args.allarch)
    if args.specs:
        constraints = set(args.specs)
        specs = [s for s in specs if any(s.satisfies(c) for c in constraints)]
    display_specs(specs, args, all_headers=True)
Exemplo n.º 2
0
def display_env(env, args, decorator):
    tty.msg('In environment %s' % env.name)

    if not env.user_specs:
        tty.msg('No root specs')
    else:
        tty.msg('Root specs')

        # Root specs cannot be displayed with prefixes, since those are not
        # set for abstract specs. Same for hashes
        root_args = copy.copy(args)
        root_args.paths = False

        # Roots are displayed with variants, etc. so that we can see
        # specifically what the user asked for.
        cmd.display_specs(
            env.user_specs,
            root_args,
            decorator=lambda s, f: color.colorize('@*{%s}' % f),
            namespace=True,
            show_flags=True,
            show_full_compiler=True,
            variants=True
        )
        print()

    if args.show_concretized:
        tty.msg('Concretized roots')
        cmd.display_specs(
            env.specs_by_hash.values(), args, decorator=decorator)
        print()
Exemplo n.º 3
0
def display_env(env, args, decorator):
    tty.msg('In environment %s' % env.name)

    if not env.user_specs:
        tty.msg('No root specs')
    else:
        tty.msg('Root specs')

        # Roots are displayed with variants, etc. so that we can see
        # specifically what the user asked for.
        cmd.display_specs(env.user_specs,
                          args,
                          decorator=lambda s, f: color.colorize('@*{%s}' % f),
                          namespace=True,
                          show_flags=True,
                          show_full_compiler=True,
                          variants=True)
        print()

    if args.show_concretized:
        tty.msg('Concretized roots')
        cmd.display_specs(env.specs_by_hash.values(),
                          args,
                          decorator=decorator)
        print()
Exemplo n.º 4
0
def extensions(parser, args):
    if not args.spec:
        tty.die("extensions requires a package spec.")

    # Checks
    spec = cmd.parse_specs(args.spec)
    if len(spec) > 1:
        tty.die("Can only list extensions for one package.")

    if not spec[0].package.extendable:
        tty.die("%s is not an extendable package." % spec[0].name)

    env = ev.get_env(args, 'extensions')
    spec = cmd.disambiguate_spec(spec[0], env)

    if not spec.package.extendable:
        tty.die("%s does not have extensions." % spec.short_spec)

    if args.show in ("packages", "all"):
        # List package names of extensions
        extensions = spack.repo.path.extensions_for(spec)
        if not extensions:
            tty.msg("%s has no extensions." % spec.cshort_spec)
        else:
            tty.msg(spec.cshort_spec)
            tty.msg("%d extensions:" % len(extensions))
            colify(ext.name for ext in extensions)

    if args.view:
        target = args.view
    else:
        target = spec.prefix

    view = YamlFilesystemView(target, spack.store.layout)

    if args.show in ("installed", "all"):
        # List specs of installed extensions.
        installed = [
            s.spec for s in spack.store.db.installed_extensions_for(spec)]

        if args.show == "all":
            print
        if not installed:
            tty.msg("None installed.")
        else:
            tty.msg("%d installed:" % len(installed))
            cmd.display_specs(installed, args)

    if args.show in ("activated", "all"):
        # List specs of activated extensions.
        activated = view.extensions_layout.extension_map(spec)
        if args.show == "all":
            print
        if not activated:
            tty.msg("None activated.")
        else:
            tty.msg("%d activated:" % len(activated))
            cmd.display_specs(activated.values(), args)
Exemplo n.º 5
0
def listspecs(args):
    """list binary packages available from mirrors"""
    specs = bindist.get_specs(args.force)
    if args.packages:
        pkgs = set(args.packages)
        specs = [s for s in specs for p in pkgs if s.satisfies(p)]
        display_specs(specs, args, all_headers=True)
    else:
        display_specs(specs, args, all_headers=True)
Exemplo n.º 6
0
def find(parser, args):
    q_args = query_arguments(args)
    # Query the current store or the internal bootstrap store if required
    if args.bootstrap:
        bootstrap_store_path = spack.bootstrap.store_path()
        msg = 'Showing internal bootstrap store at "{0}"'
        tty.msg(msg.format(bootstrap_store_path))
        with spack.store.use_store(bootstrap_store_path):
            results = args.specs(**q_args)
    else:
        results = args.specs(**q_args)

    decorator = lambda s, f: f
    added = set()
    removed = set()

    env = ev.get_env(args, 'find')
    if env:
        decorator, added, roots, removed = setup_env(env)

    # use groups by default except with format.
    if args.groups is None:
        args.groups = not args.format

    # Exit early with an error code if no package matches the constraint
    if not results and args.constraint:
        msg = "No package matches the query: {0}"
        msg = msg.format(' '.join(args.constraint))
        tty.msg(msg)
        return 1

    # If tags have been specified on the command line, filter by tags
    if args.tags:
        packages_with_tags = spack.repo.path.packages_with_tags(*args.tags)
        results = [x for x in results if x.name in packages_with_tags]

    if args.loaded:
        hashes = os.environ.get(uenv.spack_loaded_hashes_var, '').split(':')
        results = [x for x in results if x.dag_hash() in hashes]

    # Display the result
    if args.json:
        cmd.display_specs_as_json(results, deps=args.deps)
    else:
        if not args.format:
            if env:
                display_env(env, args, decorator)
        if sys.stdout.isatty() and args.groups:
            tty.msg("%s" % plural(len(results), 'installed package'))
        cmd.display_specs(results, args, decorator=decorator, all_headers=True)
Exemplo n.º 7
0
def listspecs(args):
    """list binary packages available from mirrors"""
    specs = bindist.update_cache_and_get_specs()
    if not args.allarch:
        arch = spack.architecture.default_arch().to_spec()
        specs = [s for s in specs if s.satisfies(arch)]

    if args.specs:
        constraints = set(args.specs)
        specs = [s for s in specs if any(s.satisfies(c) for c in constraints)]
    if sys.stdout.isatty():
        builds = len(specs)
        tty.msg("%s." % plural(builds, 'cached build'))
        if not builds and not args.allarch:
            tty.msg("You can query all available architectures with:",
                    "spack buildcache list --allarch")
    display_specs(specs, args, all_headers=True)
Exemplo n.º 8
0
def find(parser, args):
    q_args = query_arguments(args)
    query_specs = args.specs(**q_args)
    # Exit early if no package matches the constraint
    if not query_specs:
        msg = "No package matches the query: {0}".format(args.contraint)
        tty.msg(msg)
        return
    # Display the result
    if sys.stdout.isatty():
        tty.msg("%d installed packages." % len(query_specs))
    display_specs(query_specs,
                  mode=args.mode,
                  long=args.long,
                  very_long=args.very_long,
                  show_flags=args.show_flags,
                  namespace=args.namespace,
                  variants=args.variants)
Exemplo n.º 9
0
def display_env(env, args, decorator):
    tty.msg('In environment %s' % env.name)

    if not env.user_specs:
        tty.msg('No root specs')
    else:
        tty.msg('Root specs')
        # TODO: Change this to not print extraneous deps and variants
        cmd.display_specs(env.user_specs,
                          args,
                          decorator=lambda s, f: color.colorize('@*{%s}' % f))
        print()

    if args.show_concretized:
        tty.msg('Concretized roots')
        cmd.display_specs(env.specs_by_hash.values(),
                          args,
                          decorator=decorator)
        print()
Exemplo n.º 10
0
def _find(parser, args):
    q_args = query_arguments(args)
    results = args.specs(**q_args)

    env = ev.active_environment()
    decorator = lambda s, f: f
    if env:
        decorator, _, roots, _ = setup_env(env)

    # use groups by default except with format.
    if args.groups is None:
        args.groups = not args.format

    # Exit early with an error code if no package matches the constraint
    if not results and args.constraint:
        msg = "No package matches the query: {0}"
        msg = msg.format(' '.join(args.constraint))
        tty.msg(msg)
        raise SystemExit(1)

    # If tags have been specified on the command line, filter by tags
    if args.tags:
        packages_with_tags = spack.repo.path.packages_with_tags(*args.tags)
        results = [x for x in results if x.name in packages_with_tags]

    if args.loaded:
        results = spack.cmd.filter_loaded_specs(results)

    # Display the result
    if args.json:
        cmd.display_specs_as_json(results, deps=args.deps)
    else:
        if not args.format:
            if env:
                display_env(env, args, decorator)

        if sys.stdout.isatty() and args.groups:
            pkg_type = "loaded" if args.loaded else "installed"
            spack.cmd.print_how_many_pkgs(results, pkg_type)

        cmd.display_specs(results, args, decorator=decorator, all_headers=True)
Exemplo n.º 11
0
def find(parser, args):
    q_args = query_arguments(args)
    query_specs = args.specs(**q_args)

    # Exit early if no package matches the constraint
    if not query_specs and args.constraint:
        msg = "No package matches the query: {0}"
        msg = msg.format(' '.join(args.constraint))
        tty.msg(msg)
        return

    # If tags have been specified on the command line, filter by tags
    if args.tags:
        packages_with_tags = spack.repo.packages_with_tags(*args.tags)
        query_specs = [x for x in query_specs if x.name in packages_with_tags]

    # Display the result
    if sys.stdout.isatty():
        tty.msg("%d installed packages." % len(query_specs))

    display_specs(query_specs, args)
Exemplo n.º 12
0
def find(parser, args):
    q_args = query_arguments(args)
    query_specs = args.specs(**q_args)

    # Exit early if no package matches the constraint
    if not query_specs and args.constraint:
        msg = "No package matches the query: {0}"
        msg = msg.format(' '.join(args.constraint))
        tty.msg(msg)
        return

    # If tags have been specified on the command line, filter by tags
    if args.tags:
        packages_with_tags = spack.repo.path.packages_with_tags(*args.tags)
        query_specs = [x for x in query_specs if x.name in packages_with_tags]

    # Display the result
    if sys.stdout.isatty():
        tty.msg("%d installed packages." % len(query_specs))

    display_specs(query_specs, args)
Exemplo n.º 13
0
def find(parser, args):
    q_args = query_arguments(args)
    query_specs = args.specs(**q_args)

    # Exit early if no package matches the constraint
    if not query_specs and args.constraint:
        msg = "No package matches the query: {0}".format(
            ' '.join(args.constraint))
        tty.msg(msg)
        return

    # Display the result
    if sys.stdout.isatty():
        tty.msg("%d installed packages." % len(query_specs))

    display_specs(query_specs,
                  mode=args.mode,
                  long=args.long,
                  very_long=args.very_long,
                  show_flags=args.show_flags,
                  namespace=args.namespace,
                  variants=args.variants)
Exemplo n.º 14
0
def find(parser, args):
    q_args = query_arguments(args)
    results = args.specs(**q_args)

    decorator = lambda s, f: f
    added = set()
    removed = set()

    env = ev.get_env(args, 'find')
    if env:
        decorator, added, roots, removed = setup_env(env)

    # use groups by default except with format.
    if args.groups is None:
        args.groups = not args.format

    # Exit early with an error code if no package matches the constraint
    if not results and args.constraint:
        msg = "No package matches the query: {0}"
        msg = msg.format(' '.join(args.constraint))
        tty.msg(msg)
        return 1

    # If tags have been specified on the command line, filter by tags
    if args.tags:
        packages_with_tags = spack.repo.path.packages_with_tags(*args.tags)
        results = [x for x in results if x.name in packages_with_tags]

    # Display the result
    if args.json:
        cmd.display_specs_as_json(results, deps=args.deps)
    else:
        if env:
            display_env(env, args, decorator)
        if args.groups:
            tty.msg("%s" % plural(len(results), 'installed package'))
        cmd.display_specs(results, args, decorator=decorator, all_headers=True)
Exemplo n.º 15
0
def find(parser, args):
    q_args = query_arguments(args)
    results = args.specs(**q_args)

    decorator = lambda s, f: f
    added = set()
    removed = set()

    env = ev.get_env(args, 'find', required=False)
    if env:
        decorator, added, roots, removed = setup_env(env)

    # Exit early if no package matches the constraint
    if not results and args.constraint:
        msg = "No package matches the query: {0}"
        msg = msg.format(' '.join(args.constraint))
        tty.msg(msg)
        return

    # If tags have been specified on the command line, filter by tags
    if args.tags:
        packages_with_tags = spack.repo.path.packages_with_tags(*args.tags)
        results = [x for x in results if x.name in packages_with_tags]

    # Display the result
    if env:
        tty.msg('In environment %s' % env.name)

        if not env.user_specs:
            tty.msg('No root specs')
        else:
            tty.msg('Root specs')
            display_specs(env.user_specs,
                          args,
                          decorator=lambda s, f: color.colorize('@*{%s}' % f))
        print()

        if args.show_concretized:
            tty.msg('Concretized roots')
            display_specs(env.specs_by_hash.values(),
                          args,
                          decorator=decorator)
            print()

    tty.msg("%s" % plural(len(results), 'installed package'))

    display_specs(results, args, decorator=decorator, all_headers=True)
Exemplo n.º 16
0
Arquivo: find.py Projeto: LLNL/spack
def find(parser, args):
    q_args = query_arguments(args)
    results = args.specs(**q_args)

    decorator = lambda s, f: f
    added = set()
    removed = set()

    env = ev.get_env(args, 'find', required=False)
    if env:
        decorator, added, roots, removed = setup_env(env)

    # Exit early if no package matches the constraint
    if not results and args.constraint:
        msg = "No package matches the query: {0}"
        msg = msg.format(' '.join(args.constraint))
        tty.msg(msg)
        return

    # If tags have been specified on the command line, filter by tags
    if args.tags:
        packages_with_tags = spack.repo.path.packages_with_tags(*args.tags)
        results = [x for x in results if x.name in packages_with_tags]

    # Display the result
    if env:
        tty.msg('In environment %s' % env.name)

        if not env.user_specs:
            tty.msg('No root specs')
        else:
            tty.msg('Root specs')
            display_specs(
                env.user_specs, args,
                decorator=lambda s, f: color.colorize('@*{%s}' % f))
        print()

        if args.show_concretized:
            tty.msg('Concretized roots')
            display_specs(
                env.specs_by_hash.values(), args, decorator=decorator)
            print()

    tty.msg("%s" % plural(len(results), 'installed package'))

    display_specs(results, args, decorator=decorator, all_headers=True)
Exemplo n.º 17
0
def extensions(parser, args):
    if not args.spec:
        # If called without arguments, list all the extendable packages
        isatty = sys.stdout.isatty()
        if isatty:
            tty.info('Extendable packages:')

        extendable_pkgs = []
        for name in spack.repo.all_package_names():
            pkg = spack.repo.get(name)
            if pkg.extendable:
                extendable_pkgs.append(name)

        colify(extendable_pkgs, indent=4)
        return

    # Checks
    spec = cmd.parse_specs(args.spec)
    if len(spec) > 1:
        tty.die("Can only list extensions for one package.")

    if not spec[0].package.extendable:
        tty.die("%s is not an extendable package." % spec[0].name)

    env = ev.active_environment()
    spec = cmd.disambiguate_spec(spec[0], env)

    if not spec.package.extendable:
        tty.die("%s does not have extensions." % spec.short_spec)

    if args.show in ("packages", "all"):
        # List package names of extensions
        extensions = spack.repo.path.extensions_for(spec)
        if not extensions:
            tty.msg("%s has no extensions." % spec.cshort_spec)
        else:
            tty.msg(spec.cshort_spec)
            tty.msg("%d extensions:" % len(extensions))
            colify(ext.name for ext in extensions)

    if args.view:
        target = args.view
    else:
        target = spec.prefix

    view = YamlFilesystemView(target, spack.store.layout)

    if args.show in ("installed", "all"):
        # List specs of installed extensions.
        installed = [
            s.spec for s in spack.store.db.installed_extensions_for(spec)
        ]

        if args.show == "all":
            print
        if not installed:
            tty.msg("None installed.")
        else:
            tty.msg("%d installed:" % len(installed))
            cmd.display_specs(installed, args)

    if args.show in ("activated", "all"):
        # List specs of activated extensions.
        activated = view.extensions_layout.extension_map(spec)
        if args.show == "all":
            print
        if not activated:
            tty.msg("None activated.")
        else:
            tty.msg("%d activated:" % len(activated))
            cmd.display_specs(activated.values(), args)