env: move spack env stage into spack stage command

This commit is contained in:
Todd Gamblin 2018-10-28 12:07:46 -07:00
parent e62506571f
commit 7136274f4b
4 changed files with 15 additions and 27 deletions

View File

@ -34,7 +34,6 @@
['list', 'ls'],
['status', 'st'],
'loads',
'stage',
'uninstall',
]
@ -309,23 +308,6 @@ def env_status(args):
hashlen=None if args.very_long else 7,
install_status=True)
#
# env stage
#
def env_stage_setup_parser(subparser):
"""download all source files for all packages in an environment"""
subparser.add_argument(
'env', nargs='?', help='name of env to generate loads file for')
def env_stage(args):
env = ev.get_env(args, 'env stage')
for spec in env.specs_by_hash.values():
for dep in spec.traverse():
dep.package.do_stage()
#
# env loads
#

View File

@ -7,6 +7,7 @@
import llnl.util.tty as tty
import spack.environment as ev
import spack.repo
import spack.cmd
import spack.cmd.common.arguments as arguments
@ -28,7 +29,15 @@ def setup_parser(subparser):
def stage(parser, args):
if not args.specs:
tty.die("stage requires at least one package argument")
env = ev.get_env(args, 'stage', required=False)
if env:
tty.msg("Staging specs from environment %s" % env.name)
for spec in env.specs_by_hash.values():
for dep in spec.traverse():
dep.package.do_stage()
return
else:
tty.die("`spack stage` requires a spec or an active environment")
if args.no_checksum:
spack.config.set('config:checksum', False, scope='command_line')

View File

@ -45,10 +45,9 @@ def setup_parser(subparser):
subparser.add_argument(
'-a', '--all', action='store_true', dest='all',
help="USE CAREFULLY. remove ALL installed packages that match each "
"supplied spec. i.e., if you say uninstall `libelf`,"
"supplied spec. i.e., if you `uninstall --all libelf`,"
" ALL versions of `libelf` are uninstalled. if no spec is "
"supplied all installed software will be uninstalled. this "
"is both useful and dangerous, like rm -r")
"supplied all installed software will be uninstalled.")
subparser.add_argument(
'packages',
@ -175,7 +174,6 @@ def get_uninstall_list(args, specs):
def uninstall_specs(args, specs):
uninstall_list = get_uninstall_list(args, specs)
if not uninstall_list:

View File

@ -26,6 +26,7 @@
add = SpackCommand('add')
remove = SpackCommand('remove')
concretize = SpackCommand('concretize')
stage = SpackCommand('stage')
def test_add():
@ -510,13 +511,13 @@ def test_env_loads(install_mockery, mock_fetch):
@pytest.mark.disable_clean_stage_check
def test_env_stage(mock_stage, mock_fetch, install_mockery):
def test_stage(mock_stage, mock_fetch, install_mockery):
env('create', 'test')
with ev.read('test'):
add('mpileaks')
add('zmpi')
concretize()
env('stage', 'test')
stage()
root = str(mock_stage)
@ -540,8 +541,6 @@ def test_env_commands_die_with_no_env_arg():
# these have an optional env arg and raise errors via tty.die
with pytest.raises(spack.main.SpackCommandError):
env('loads')
with pytest.raises(spack.main.SpackCommandError):
env('stage')
with pytest.raises(spack.main.SpackCommandError):
env('uninstall')