env: add --env argument to spack location

This commit is contained in:
Todd Gamblin 2018-08-07 00:35:06 -07:00
parent 47e60d5ef8
commit 180d804615
2 changed files with 12 additions and 11 deletions

View File

@ -36,7 +36,6 @@
'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;

View File

@ -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)