diff options
author | George Hartzell <hartzell@alerce.com> | 2017-02-03 15:42:46 -0800 |
---|---|---|
committer | Todd Gamblin <tgamblin@llnl.gov> | 2017-02-03 15:42:46 -0800 |
commit | 5a836fd06eb5a0042ce4b245a858a77129703d38 (patch) | |
tree | a5d9e8bf16a077272a881075387c81369f79ead0 /lib | |
parent | acb9281dbf41c30535d18a9adb432e218b1f22b3 (diff) | |
download | spack-5a836fd06eb5a0042ce4b245a858a77129703d38.tar.gz spack-5a836fd06eb5a0042ce4b245a858a77129703d38.tar.bz2 spack-5a836fd06eb5a0042ce4b245a858a77129703d38.tar.xz spack-5a836fd06eb5a0042ce4b245a858a77129703d38.zip |
Blacklist implicit packages for modulefile generation (#2603)
Add the ability to the modules generation process to blacklist
packages that were installed implicitly. One can still whitelist
modules that were installed implicitly.
This changes adds a `blacklist_implicts` boolean as a peer to the
`whitelist` and `blacklist` arrays, e.g.:
```
modules:
enable::
- lmod
lmod:
whitelist:
- 'lua'
- 'py-setuptools'
blacklist:
- '%gcc@4.8.3'
blacklist_implicits: True
```
It adds a small helper in `spec.py` and then touches up the package
filtering code in `modules.py`.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/modules.py | 12 | ||||
-rw-r--r-- | lib/spack/spack/spec.py | 10 |
2 files changed, 21 insertions, 1 deletions
diff --git a/lib/spack/spack/modules.py b/lib/spack/spack/modules.py index 5e2a840e14..ba220291a0 100644 --- a/lib/spack/spack/modules.py +++ b/lib/spack/spack/modules.py @@ -327,6 +327,10 @@ class EnvModule(object): blacklist_matches = [x for x in configuration.get('blacklist', []) if self.spec.satisfies(x)] + blacklist_implicits = configuration.get('blacklist_implicits') + installed_implicitly = not self.spec._installed_explicitly() + blacklisted_as_implicit = blacklist_implicits and installed_implicitly + if whitelist_matches: message = '\tWHITELIST : %s [matches : ' % self.spec.cshort_spec for rule in whitelist_matches: @@ -341,7 +345,13 @@ class EnvModule(object): message += ' ]' tty.debug(message) - if not whitelist_matches and blacklist_matches: + if blacklisted_as_implicit: + message = '\tBLACKLISTED_AS_IMPLICIT : %s' % \ + self.spec.cshort_spec + tty.debug(message) + + is_blacklisted = blacklist_matches or blacklisted_as_implicit + if not whitelist_matches and is_blacklisted: return True return False diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py index 07e3221ed7..36806b757d 100644 --- a/lib/spack/spack/spec.py +++ b/lib/spack/spack/spec.py @@ -2596,6 +2596,16 @@ class Spec(object): except KeyError: return None + def _installed_explicitly(self): + """Helper for tree to print DB install status.""" + if not self.concrete: + return None + try: + record = spack.store.db.get_record(self) + return record.explicit + except KeyError: + return None + def tree(self, **kwargs): """Prints out this spec and its dependencies, tree-formatted with indentation.""" |