Skip to content

Commit

Permalink
Handle cli args -> package installer args in cmd, not in environment
Browse files Browse the repository at this point in the history
  • Loading branch information
haampie committed Aug 18, 2021
1 parent adedfec commit c9f4ad2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 20 deletions.
10 changes: 5 additions & 5 deletions lib/spack/spack/cmd/install.py
Expand Up @@ -324,6 +324,10 @@ def get_tests(specs):
else:
return False

# Parse cli arguments and construct a dictionary
# that will be passed to the package installer
update_kwargs_from_args(args, kwargs)

if not args.spec and not args.specfiles:
# if there are no args but an active environment
# then install the packages from it.
Expand Down Expand Up @@ -352,7 +356,7 @@ def get_tests(specs):

tty.msg("Installing environment {0}".format(env.name))
with reporter('build'):
env.install_all(args, **kwargs)
env.install_all(**kwargs)

tty.debug("Regenerating environment views for {0}"
.format(env.name))
Expand Down Expand Up @@ -381,10 +385,6 @@ def get_tests(specs):
if args.deprecated:
spack.config.set('config:deprecated', True, scope='command_line')

# Parse cli arguments and construct a dictionary
# that will be passed to the package installer
update_kwargs_from_args(args, kwargs)

# 1. Abstract specs from cli
abstract_specs = spack.cmd.parse_specs(args.spec)
tests = get_tests(abstract_specs)
Expand Down
20 changes: 5 additions & 15 deletions lib/spack/spack/environment.py
Expand Up @@ -43,6 +43,7 @@
from spack.spec_list import InvalidSpecConstraintError, SpecList
from spack.util.path import substitute_path_variables
from spack.variant import UnknownVariantError
from spack.installer import PackageInstaller

#: environment variable used to indicate the active environment
spack_env_var = 'SPACK_ENV'
Expand Down Expand Up @@ -1469,21 +1470,18 @@ def uninstalled_specs(self):
uninstalled_specs.append(spec)
return uninstalled_specs

def install_all(self, args=None, **install_args):
def install_all(self, **install_args):
"""Install all concretized specs in an environment.
Note: this does not regenerate the views for the environment;
that needs to be done separately with a call to write().
Args:
args (argparse.Namespace): argparse namespace with command arguments
install_args (dict): keyword install arguments
"""
self.install_specs(None, args=args, **install_args)

def install_specs(self, specs=None, args=None, **install_args):
from spack.installer import PackageInstaller
self.install_specs(None, **install_args)

def install_specs(self, specs=None, **install_args):
tty.debug('Assessing installation status of environment packages')
# If "spack install" is invoked repeatedly for a large environment
# where all specs are already installed, the operation can take
Expand Down Expand Up @@ -1517,15 +1515,7 @@ def install_specs(self, specs=None, args=None, **install_args):

installs = []
for spec in specs_to_install:
# Parse cli arguments and construct a dictionary
# that will be passed to the package installer
kwargs = dict()
if install_args:
kwargs.update(install_args)
if args:
spack.cmd.install.update_kwargs_from_args(args, kwargs)

installs.append((spec.package, kwargs))
installs.append((spec.package, install_args))

try:
builder = PackageInstaller(installs)
Expand Down

0 comments on commit c9f4ad2

Please sign in to comment.