Merge branch 'features/better-find' into develop
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
from external import argparse
|
||||
|
||||
import llnl.util.tty as tty
|
||||
from llnl.util.tty.color import colorize
|
||||
from llnl.util.tty.colify import colify
|
||||
from llnl.util.lang import index_by
|
||||
|
||||
@@ -96,9 +97,12 @@ def compiler_info(args):
|
||||
def compiler_list(args):
|
||||
tty.msg("Available compilers")
|
||||
index = index_by(spack.compilers.all_compilers(), 'name')
|
||||
for name, compilers in index.items():
|
||||
tty.hline(name, char='-', color=spack.spec.compiler_color)
|
||||
colify(reversed(sorted(compilers)), indent=4)
|
||||
for i, (name, compilers) in enumerate(index.items()):
|
||||
if i >= 1: print
|
||||
|
||||
cname = "%s{%s}" % (spack.spec.compiler_color, name)
|
||||
tty.hline(colorize(cname), char='-')
|
||||
colify(reversed(sorted(compilers)))
|
||||
|
||||
|
||||
def compiler(parser, args):
|
||||
|
||||
@@ -24,13 +24,14 @@
|
||||
##############################################################################
|
||||
import sys
|
||||
import collections
|
||||
import itertools
|
||||
from external import argparse
|
||||
from StringIO import StringIO
|
||||
|
||||
import llnl.util.tty as tty
|
||||
from llnl.util.tty.colify import colify
|
||||
from llnl.util.tty.colify import *
|
||||
from llnl.util.tty.color import *
|
||||
from llnl.util.lang import partition_list, index_by
|
||||
from llnl.util.lang import *
|
||||
|
||||
import spack
|
||||
import spack.spec
|
||||
@@ -39,12 +40,15 @@
|
||||
|
||||
def setup_parser(subparser):
|
||||
format_group = subparser.add_mutually_exclusive_group()
|
||||
format_group.add_argument(
|
||||
'-l', '--long', action='store_true', dest='long',
|
||||
help='Show dependency hashes as well as versions.')
|
||||
format_group.add_argument(
|
||||
'-p', '--paths', action='store_true', dest='paths',
|
||||
help='Show paths to package install directories')
|
||||
format_group.add_argument(
|
||||
'-l', '--long', action='store_true', dest='full_specs',
|
||||
help='Show full-length specs of installed packages')
|
||||
'-d', '--deps', action='store_true', dest='full_deps',
|
||||
help='Show full dependency DAG of installed packages')
|
||||
|
||||
subparser.add_argument(
|
||||
'query_specs', nargs=argparse.REMAINDER,
|
||||
@@ -65,39 +69,43 @@ def find(parser, args):
|
||||
if not query_specs:
|
||||
return
|
||||
|
||||
specs = [s for s in spack.db.installed_package_specs()
|
||||
if not query_specs or any(s.satisfies(q) for q in query_specs)]
|
||||
# Get all the specs the user asked for
|
||||
if not query_specs:
|
||||
specs = set(spack.db.installed_package_specs())
|
||||
else:
|
||||
results = [set(spack.db.get_installed(qs)) for qs in query_specs]
|
||||
specs = set.union(*results)
|
||||
|
||||
# Make a dict with specs keyed by architecture and compiler.
|
||||
index = index_by(specs, 'architecture', 'compiler')
|
||||
index = index_by(specs, ('architecture', 'compiler'))
|
||||
|
||||
# Traverse the index and print out each package
|
||||
for architecture in index:
|
||||
tty.hline(architecture, char='=', color=spack.spec.architecture_color)
|
||||
for compiler in index[architecture]:
|
||||
tty.hline(compiler, char='-', color=spack.spec.compiler_color)
|
||||
for i, (architecture, compiler) in enumerate(sorted(index)):
|
||||
if i > 0: print
|
||||
|
||||
specs = index[architecture][compiler]
|
||||
specs.sort()
|
||||
header = "%s{%s} / %s{%s}" % (
|
||||
spack.spec.architecture_color, architecture,
|
||||
spack.spec.compiler_color, compiler)
|
||||
tty.hline(colorize(header), char='-')
|
||||
|
||||
abbreviated = [s.format('$_$@$+$#', color=True) for s in specs]
|
||||
specs = index[(architecture,compiler)]
|
||||
specs.sort()
|
||||
|
||||
if args.paths:
|
||||
# Print one spec per line along with prefix path
|
||||
width = max(len(s) for s in abbreviated)
|
||||
width += 2
|
||||
format = " %-{}s%s".format(width)
|
||||
abbreviated = [s.format('$_$@$+', color=True) for s in specs]
|
||||
if args.paths:
|
||||
# Print one spec per line along with prefix path
|
||||
width = max(len(s) for s in abbreviated)
|
||||
width += 2
|
||||
format = " %-{}s%s".format(width)
|
||||
|
||||
for abbrv, spec in zip(abbreviated, specs):
|
||||
print format % (abbrv, spec.prefix)
|
||||
for abbrv, spec in zip(abbreviated, specs):
|
||||
print format % (abbrv, spec.prefix)
|
||||
|
||||
elif args.full_specs:
|
||||
for spec in specs:
|
||||
print spec.tree(indent=4, format='$_$@$+', color=True),
|
||||
else:
|
||||
max_len = max([len(s.name) for s in specs])
|
||||
max_len += 4
|
||||
|
||||
for spec in specs:
|
||||
format = '$-' + str(max_len) + '_$@$+$#'
|
||||
print " " + spec.format(format, color=True)
|
||||
elif args.full_deps:
|
||||
for spec in specs:
|
||||
print spec.tree(indent=4, format='$_$@$+', color=True),
|
||||
else:
|
||||
fmt = '$-_$@$+'
|
||||
if args.long:
|
||||
fmt += '$#'
|
||||
colify(s.format(fmt, color=True) for s in specs)
|
||||
|
||||
@@ -61,5 +61,4 @@ def match(p, f):
|
||||
indent=0
|
||||
if sys.stdout.isatty():
|
||||
tty.msg("%d packages." % len(sorted_packages))
|
||||
indent=2
|
||||
colify(sorted_packages, indent=indent)
|
||||
|
||||
Reference in New Issue
Block a user