environment.py: allow link:run (#29336)

* environment.py: allow link:run

Some users want minimal views, excluding run-type dependencies, since
those type of dependencies are covered by rpaths and the symlinked
libraries in the view aren't used anyways.

With this change, an environment like this:

```
spack:
  specs: ['py-flake8']
  view:
    default:
      root: view
      link: run
```

includes python packages and python, but no link type deps of python.
This commit is contained in:
Harmen Stoppels
2022-03-09 21:35:26 +01:00
committed by GitHub
parent bedc9fe665
commit dc78f4c58a
6 changed files with 148 additions and 87 deletions

View File

@@ -589,20 +589,31 @@ def match(string):
return match
def dedupe(sequence):
"""Yields a stable de-duplication of an hashable sequence
def dedupe(sequence, key=None):
"""Yields a stable de-duplication of an hashable sequence by key
Args:
sequence: hashable sequence to be de-duplicated
key: callable applied on values before uniqueness test; identity
by default.
Returns:
stable de-duplication of the sequence
Examples:
Dedupe a list of integers:
[x for x in dedupe([1, 2, 1, 3, 2])] == [1, 2, 3]
[x for x in llnl.util.lang.dedupe([1,-2,1,3,2], key=abs)] == [1, -2, 3]
"""
seen = set()
for x in sequence:
if x not in seen:
x_key = x if key is None else key(x)
if x_key not in seen:
yield x
seen.add(x)
seen.add(x_key)
def pretty_date(time, now=None):