Add config parameter for active upstream to set install location for modules

This commit is contained in:
Carson Woods
2019-07-18 13:50:25 -06:00
parent a7ad344c2a
commit 9ab7d8f01d
4 changed files with 28 additions and 2 deletions

View File

@@ -207,6 +207,8 @@ def install(spec, kwargs):
spec.package.do_install(**kwargs)
spack.config.set('config:active_tree', '~/.spack/opt/spack',
scope='user')
spack.config.set('config:active_upstream', None,
scope='user')
try:
if cli_args.things_to_install == 'dependencies':

View File

@@ -88,6 +88,8 @@ def find_matching_specs(env, specs, allow_multiple_matches=False, force=False,
list of specs
"""
if global_uninstall:
spack.config.set('config:active_upstream', 'global',
scope='user')
global_root = spack.config.get('upstreams')
global_root = global_root['global']['install_tree']
global_root = spack.util.path.canonicalize_path(global_root)
@@ -96,11 +98,15 @@ def find_matching_specs(env, specs, allow_multiple_matches=False, force=False,
elif upstream:
if upstream not in spack.config.get('upstreams'):
tty.die("specified upstream does not exist")
spack.config.set('config:active_upstream', upstream,
scope='user')
root = spack.config.get('upstreams')
root = root[upstream]['install_tree']
root = spack.util.path.canonicalize_path(root)
spack.config.set('config:active_tree', root, scope='user')
else:
spack.config.set('config:active_upstream', None,
scope='user')
for spec in specs:
if isinstance(spec, spack.spec.Spec):
spec_name = str(spec)
@@ -276,6 +282,8 @@ def do_uninstall(env, specs, force):
'~/.spack/opt/spack',
scope='user')
spack.config.set('config:active_upstream', None,
scope='user')
def get_uninstall_list(args, specs, env):
# Gets the list of installed specs that match the ones give via cli

View File

@@ -214,12 +214,21 @@ def root_path(name):
"""Returns the root folder for module file installation.
Args:
name: name of the module system t be used (e.g. 'tcl')
name: name of the module system to be used (e.g. 'tcl')
Returns:
root folder for module file installation
"""
path = roots.get(name, os.path.join(spack.paths.share_path, name))
# Determine where to install modules too
active_upstream = spack.config.get('config:active_upstream')
if active_upstream:
root_name = 'upstreams:' + active_upstream + ":modules:" + name
path = spack.config.get(root_name, os.path.join(spack.paths.share_path, name))
else:
path = roots.get(name, os.path.join(spack.paths.share_path, name))
return spack.util.path.canonicalize_path(path)
@@ -284,6 +293,7 @@ def read_module_indices():
module_type_to_index = {}
module_type_to_root = install_properties.get('modules', {})
for module_type, root in module_type_to_root.items():
root = spack.util.path.canonicalize_path(root)
module_type_to_index[module_type] = read_module_index(root)
module_indices.append(module_type_to_index)

View File

@@ -1496,6 +1496,8 @@ def do_install(self, **kwargs):
# Install Package to Global Upstream for multi-user use
if install_global:
spack.config.set('config:active_upstream', 'global',
scope='user')
global_root = spack.config.get('upstreams')
global_root = global_root['global']['install_tree']
global_root = spack.util.path.canonicalize_path(global_root)
@@ -1504,11 +1506,15 @@ def do_install(self, **kwargs):
elif upstream:
if upstream not in spack.config.get('upstreams'):
tty.die("specified upstream does not exist")
spack.config.set('config:active_upstream', upstream,
scope='user')
root = spack.config.get('upstreams')
root = root[upstream]['install_tree']
root = spack.util.path.canonicalize_path(root)
spack.config.set('config:active_tree', root, scope='user')
else:
spack.config.set('config:active_upstream', None,
scope='user')
spack.config.set('config:active_tree',
spack.config.get('config:install_tree'),
scope='user')