summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2018-08-07 00:35:06 -0700
committerTodd Gamblin <tgamblin@llnl.gov>2018-11-09 00:31:24 -0800
commit180d804615d242b9b6eabf244429eb4fc82fb2b1 (patch)
tree52a2852554d614b31291838175c5669bb83ccc91 /lib
parent47e60d5ef8c539c3abe99c6d7d3d721730268397 (diff)
downloadspack-180d804615d242b9b6eabf244429eb4fc82fb2b1.tar.gz
spack-180d804615d242b9b6eabf244429eb4fc82fb2b1.tar.bz2
spack-180d804615d242b9b6eabf244429eb4fc82fb2b1.tar.xz
spack-180d804615d242b9b6eabf244429eb4fc82fb2b1.zip
env: add `--env` argument to `spack location`
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/cmd/env.py10
-rw-r--r--lib/spack/spack/cmd/location.py13
2 files changed, 12 insertions, 11 deletions
diff --git a/lib/spack/spack/cmd/env.py b/lib/spack/spack/cmd/env.py
index ad7750671e..da089c35c4 100644
--- a/lib/spack/spack/cmd/env.py
+++ b/lib/spack/spack/cmd/env.py
@@ -36,7 +36,6 @@ subcommands = [
'concretize',
'list',
'loads',
- 'location',
'relocate',
'stage',
'install',
@@ -263,15 +262,6 @@ def environment_stage(args):
dep.package.do_stage()
-def setup_location_parser(subparser):
- """print the root directory of the environment"""
-
-
-def environment_location(args):
- environment = ev.read(args.environment)
- print(environment.path)
-
-
@contextmanager
def redirect_stdout(ofname):
"""Redirects STDOUT to (by default) a file within the environment;
diff --git a/lib/spack/spack/cmd/location.py b/lib/spack/spack/cmd/location.py
index 396128f089..c97075441d 100644
--- a/lib/spack/spack/cmd/location.py
+++ b/lib/spack/spack/cmd/location.py
@@ -5,11 +5,13 @@
from __future__ import print_function
+import os
import argparse
import llnl.util.tty as tty
-import spack.paths
import spack.cmd
+import spack.environment
+import spack.paths
import spack.repo
description = "print out locations of various directories used by Spack"
@@ -47,6 +49,9 @@ def setup_parser(subparser):
'-b', '--build-dir', action='store_true',
help="checked out or expanded source directory for a spec "
"(requires it to be staged first)")
+ directories.add_argument(
+ '-e', '--env', action='store',
+ help="location of an environment managed by spack")
subparser.add_argument(
'spec', nargs=argparse.REMAINDER,
@@ -60,6 +65,12 @@ def location(parser, args):
elif args.spack_root:
print(spack.paths.prefix)
+ elif args.env:
+ path = spack.environment.root(args.env)
+ if not os.path.isdir(path):
+ tty.die("no such environment: '%s'" % args.env)
+ print(path)
+
elif args.packages:
print(spack.repo.path.first_repo().root)