Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Spack
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
eic_tools
Spack
Commits
23c70897
Commit
23c70897
authored
8 years ago
by
Massimiliano Culpo
Browse files
Options
Downloads
Patches
Plain Diff
fixes #967, flake8 approved
parent
fcc30cbf
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/spack/spack/cmd/find.py
+82
-53
82 additions, 53 deletions
lib/spack/spack/cmd/find.py
with
82 additions
and
53 deletions
lib/spack/spack/cmd/find.py
+
82
−
53
View file @
23c70897
...
...
@@ -22,66 +22,92 @@
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##############################################################################
import
sys
import
collections
import
itertools
import
argparse
from
StringIO
import
StringIO
import
sys
import
llnl.util.tty
as
tty
import
spack
import
spack.spec
from
llnl.util.lang
import
*
from
llnl.util.tty.colify
import
*
from
llnl.util.tty.color
import
*
from
llnl.util.lang
import
*
import
spack
import
spack.spec
description
=
"
Find installed spack packages
"
description
=
"
Find installed spack packages
"
def
setup_parser
(
subparser
):
format_group
=
subparser
.
add_mutually_exclusive_group
()
format_group
.
add_argument
(
'
-s
'
,
'
--short
'
,
action
=
'
store_const
'
,
dest
=
'
mode
'
,
const
=
'
short
'
,
help
=
'
Show only specs (default)
'
)
format_group
.
add_argument
(
'
-p
'
,
'
--paths
'
,
action
=
'
store_const
'
,
dest
=
'
mode
'
,
const
=
'
paths
'
,
help
=
'
Show paths to package install directories
'
)
format_group
.
add_argument
(
'
-s
'
,
'
--short
'
,
action
=
'
store_const
'
,
dest
=
'
mode
'
,
const
=
'
short
'
,
help
=
'
Show only specs (default)
'
)
format_group
.
add_argument
(
'
-p
'
,
'
--paths
'
,
action
=
'
store_const
'
,
dest
=
'
mode
'
,
const
=
'
paths
'
,
help
=
'
Show paths to package install directories
'
)
format_group
.
add_argument
(
'
-d
'
,
'
--deps
'
,
action
=
'
store_const
'
,
dest
=
'
mode
'
,
const
=
'
deps
'
,
'
-d
'
,
'
--deps
'
,
action
=
'
store_const
'
,
dest
=
'
mode
'
,
const
=
'
deps
'
,
help
=
'
Show full dependency DAG of installed packages
'
)
subparser
.
add_argument
(
'
-l
'
,
'
--long
'
,
action
=
'
store_true
'
,
dest
=
'
long
'
,
help
=
'
Show dependency hashes as well as versions.
'
)
subparser
.
add_argument
(
'
-L
'
,
'
--very-long
'
,
action
=
'
store_true
'
,
dest
=
'
very_long
'
,
help
=
'
Show dependency hashes as well as versions.
'
)
subparser
.
add_argument
(
'
-f
'
,
'
--show-flags
'
,
action
=
'
store_true
'
,
dest
=
'
show_flags
'
,
help
=
'
Show spec compiler flags.
'
)
subparser
.
add_argument
(
'
-l
'
,
'
--long
'
,
action
=
'
store_true
'
,
dest
=
'
long
'
,
help
=
'
Show dependency hashes as well as versions.
'
)
subparser
.
add_argument
(
'
-L
'
,
'
--very-long
'
,
action
=
'
store_true
'
,
dest
=
'
very_long
'
,
help
=
'
Show dependency hashes as well as versions.
'
)
subparser
.
add_argument
(
'
-f
'
,
'
--show-flags
'
,
action
=
'
store_true
'
,
dest
=
'
show_flags
'
,
help
=
'
Show spec compiler flags.
'
)
subparser
.
add_argument
(
'
-e
'
,
'
--explicit
'
,
action
=
'
store_true
'
,
'
-e
'
,
'
--explicit
'
,
action
=
'
store_true
'
,
help
=
'
Show only specs that were installed explicitly
'
)
subparser
.
add_argument
(
'
-E
'
,
'
--implicit
'
,
action
=
'
store_true
'
,
'
-E
'
,
'
--implicit
'
,
action
=
'
store_true
'
,
help
=
'
Show only specs that were installed as dependencies
'
)
subparser
.
add_argument
(
'
-u
'
,
'
--unknown
'
,
action
=
'
store_true
'
,
dest
=
'
unknown
'
,
'
-u
'
,
'
--unknown
'
,
action
=
'
store_true
'
,
dest
=
'
unknown
'
,
help
=
'
Show only specs Spack does not have a package for.
'
)
subparser
.
add_argument
(
'
-m
'
,
'
--missing
'
,
action
=
'
store_true
'
,
dest
=
'
missing
'
,
'
-m
'
,
'
--missing
'
,
action
=
'
store_true
'
,
dest
=
'
missing
'
,
help
=
'
Show missing dependencies as well as installed specs.
'
)
subparser
.
add_argument
(
'
-M
'
,
'
--only-missing
'
,
action
=
'
store_true
'
,
dest
=
'
only_missing
'
,
help
=
'
Show only missing dependencies.
'
)
subparser
.
add_argument
(
'
-N
'
,
'
--namespace
'
,
action
=
'
store_true
'
,
help
=
'
Show fully qualified package names.
'
)
subparser
.
add_argument
(
'
-M
'
,
'
--only-missing
'
,
action
=
'
store_true
'
,
dest
=
'
only_missing
'
,
help
=
'
Show only missing dependencies.
'
)
subparser
.
add_argument
(
'
-N
'
,
'
--namespace
'
,
action
=
'
store_true
'
,
help
=
'
Show fully qualified package names.
'
)
subparser
.
add_argument
(
'
query_specs
'
,
nargs
=
argparse
.
REMAINDER
,
help
=
'
optional specs to filter results
'
)
subparser
.
add_argument
(
'
query_specs
'
,
nargs
=
argparse
.
REMAINDER
,
help
=
'
optional specs to filter results
'
)
def
gray_hash
(
spec
,
length
):
...
...
@@ -109,14 +135,15 @@ def display_specs(specs, **kwargs):
# Traverse the index and print out each package
for
i
,
(
architecture
,
compiler
)
in
enumerate
(
sorted
(
index
)):
if
i
>
0
:
print
if
i
>
0
:
print
header
=
"
%s{%s} / %s{%s}
"
%
(
spack
.
spec
.
architecture_color
,
architecture
,
spack
.
spec
.
compiler_color
,
compiler
)
header
=
"
%s{%s} / %s{%s}
"
%
(
spack
.
spec
.
architecture_color
,
architecture
,
spack
.
spec
.
compiler_color
,
compiler
)
tty
.
hline
(
colorize
(
header
),
char
=
'
-
'
)
specs
=
index
[(
architecture
,
compiler
)]
specs
=
index
[(
architecture
,
compiler
)]
specs
.
sort
()
abbreviated
=
[
s
.
format
(
format_string
,
color
=
True
)
for
s
in
specs
]
...
...
@@ -128,20 +155,21 @@ def display_specs(specs, **kwargs):
for
abbrv
,
spec
in
zip
(
abbreviated
,
specs
):
if
hashes
:
print
gray_hash
(
spec
,
hlen
),
print
format
%
(
abbrv
,
spec
.
prefix
)
print
(
gray_hash
(
spec
,
hlen
),
)
print
(
format
%
(
abbrv
,
spec
.
prefix
)
)
elif
mode
==
'
deps
'
:
for
spec
in
specs
:
print
spec
.
tree
(
print
(
spec
.
tree
(
format
=
format_string
,
color
=
True
,
indent
=
4
,
prefix
=
(
lambda
s
:
gray_hash
(
s
,
hlen
))
if
hashes
else
None
)
prefix
=
(
lambda
s
:
gray_hash
(
s
,
hlen
))
if
hashes
else
None
)
)
elif
mode
==
'
short
'
:
# Print columns of output if not printing flags
if
not
flags
:
def
fmt
(
s
):
string
=
""
if
hashes
:
...
...
@@ -149,18 +177,17 @@ def fmt(s):
string
+=
s
.
format
(
'
$-%s$@$+
'
%
nfmt
,
color
=
True
)
return
string
colify
(
fmt
(
s
)
for
s
in
specs
)
# Print one entry per line if including flags
else
:
for
spec
in
specs
:
# Print the hash if necessary
hsh
=
gray_hash
(
spec
,
hlen
)
+
'
'
if
hashes
else
''
print
hsh
+
spec
.
format
(
format_string
,
color
=
True
)
+
'
\n
'
print
(
hsh
+
spec
.
format
(
format_string
,
color
=
True
)
+
'
\n
'
)
else
:
raise
ValueError
(
"
Invalid mode for display_specs: %s. Must be one of (paths, deps, short).
"
%
mode
)
raise
ValueError
(
"
Invalid mode for display_specs: %s. Must be one of (paths, deps, short).
"
%
mode
)
# NOQA: ignore=E501
def
find
(
parser
,
args
):
...
...
@@ -192,13 +219,14 @@ def find(parser, args):
if
args
.
implicit
:
explicit
=
True
q_args
=
{
'
installed
'
:
installed
,
'
known
'
:
known
,
"
explicit
"
:
explicit
}
q_args
=
{
'
installed
'
:
installed
,
'
known
'
:
known
,
"
explicit
"
:
explicit
}
# Get all the specs the user asked for
if
not
query_specs
:
specs
=
set
(
spack
.
installed_db
.
query
(
**
q_args
))
else
:
results
=
[
set
(
spack
.
installed_db
.
query
(
qs
,
**
q_args
))
for
qs
in
query_specs
]
results
=
[
set
(
spack
.
installed_db
.
query
(
qs
,
**
q_args
))
for
qs
in
query_specs
]
specs
=
set
.
union
(
*
results
)
if
not
args
.
mode
:
...
...
@@ -206,7 +234,8 @@ def find(parser, args):
if
sys
.
stdout
.
isatty
():
tty
.
msg
(
"
%d installed packages.
"
%
len
(
specs
))
display_specs
(
specs
,
mode
=
args
.
mode
,
display_specs
(
specs
,
mode
=
args
.
mode
,
long
=
args
.
long
,
very_long
=
args
.
very_long
,
show_flags
=
args
.
show_flags
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment