Maintain a view for an environment (#10017)
Environments are nowm by default, created with views. When activated, if an environment includes a view, this view will be added to `PATH`, `CPATH`, and other shell variables to expose the Spack environment in the user's shell. Example: ``` spack env create e1 #by default this will maintain a view in the directory Spack maintains for the env spack env create e1 --with-view=/abs/path/to/anywhere spack env create e1 --without-view ``` The `spack.yaml` manifest file now looks like this: ``` spack: specs: - python view: true #or false, or a string ``` These commands can be used to control the view configuration for the active environment, without hand-editing the `spack.yaml` file: ``` spack env view enable spack env view envable /abs/path/to/anywhere spack env view disable ``` Views are automatically updated when specs are installed to an environment. A view only maintains one copy of any package. An environment may refer to a package multiple times, in particular if it appears as a dependency. This PR establishes a prioritization for which environment specs are added to views: a spec has higher priority if it was concretized first. This does not necessarily exactly match the order in which specs were added, for example, given `X->Z` and `Y->Z'`: ``` spack env activate e1 spack add X spack install Y # immediately concretizes and installs Y and Z' spack install # concretizes X and Z ``` In this case `Z'` will be favored over `Z`. Specs in the environment must be concrete and installed to be added to the view, so there is another minor ordering effect: by default the view maintained for the environment ignores file conflicts between packages. If packages are not installed in order, and there are file conflicts, then the version chosen depends on the order. Both ordering issues are avoided if `spack install`/`spack add` and `spack install <spec>` are not mixed.
This commit is contained in:

committed by
Todd Gamblin

parent
8f1ebfc73c
commit
ea1de6b941
@@ -703,15 +703,32 @@ def set_executable(path):
|
||||
os.chmod(path, mode)
|
||||
|
||||
|
||||
def remove_empty_directories(root):
|
||||
"""Ascend up from the leaves accessible from `root` and remove empty
|
||||
directories.
|
||||
|
||||
Parameters:
|
||||
root (str): path where to search for empty directories
|
||||
"""
|
||||
for dirpath, subdirs, files in os.walk(root, topdown=False):
|
||||
for sd in subdirs:
|
||||
sdp = os.path.join(dirpath, sd)
|
||||
try:
|
||||
os.rmdir(sdp)
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
|
||||
def remove_dead_links(root):
|
||||
"""Removes any dead link that is present in root.
|
||||
"""Recursively removes any dead link that is present in root.
|
||||
|
||||
Parameters:
|
||||
root (str): path where to search for dead links
|
||||
"""
|
||||
for file in os.listdir(root):
|
||||
path = join_path(root, file)
|
||||
remove_if_dead_link(path)
|
||||
for dirpath, subdirs, files in os.walk(root, topdown=False):
|
||||
for f in files:
|
||||
path = join_path(dirpath, f)
|
||||
remove_if_dead_link(path)
|
||||
|
||||
|
||||
def remove_if_dead_link(path):
|
||||
|
Reference in New Issue
Block a user