diff options
-rw-r--r-- | lib/spack/docs/tutorial_modules.rst | 20 | ||||
-rw-r--r-- | lib/spack/spack/schema/modules.py | 4 | ||||
-rw-r--r-- | lib/spack/spack/test/conftest.py | 2 | ||||
-rw-r--r-- | lib/spack/spack/test/data/modules/tcl/blacklist_implicits.yaml | 6 | ||||
-rw-r--r-- | lib/spack/spack/test/modules/tcl.py | 21 |
5 files changed, 52 insertions, 1 deletions
diff --git a/lib/spack/docs/tutorial_modules.rst b/lib/spack/docs/tutorial_modules.rst index 1ae4bd79ea..59a52b87df 100644 --- a/lib/spack/docs/tutorial_modules.rst +++ b/lib/spack/docs/tutorial_modules.rst @@ -555,6 +555,26 @@ you'll see that now the module for ``gcc@7.2.0`` has reappeared: Use "module keyword key1 key2 ..." to search for all possible modules matching any of the "keys". +An additional possibility that you can leverage to unclutter the environment +is that of preventing the generation of module files for implicitly installed +packages. In this case all one needs to do is to add the following line: + +.. code-block:: yaml + :emphasize-lines: 3 + + modules: + tcl: + blacklist_implicits: true + whitelist: + - gcc + blacklist: + - '%gcc@5.4.0' + all: + filter: + environment_blacklist: ['CPATH', 'LIBRARY_PATH'] + +to ``modules.yaml`` and regenerate the module file tree as above. + ^^^^^^^^^^^^^^^^^^^^^^^^^ Change module file naming ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/lib/spack/spack/schema/modules.py b/lib/spack/spack/schema/modules.py index efd093a9cb..458b40b81d 100644 --- a/lib/spack/spack/schema/modules.py +++ b/lib/spack/spack/schema/modules.py @@ -121,6 +121,10 @@ schema = { '$ref': '#/definitions/array_of_strings'}, 'blacklist': { '$ref': '#/definitions/array_of_strings'}, + 'blacklist_implicits': { + 'type': 'boolean', + 'default': False + }, 'naming_scheme': { 'type': 'string' # Can we be more specific here? } diff --git a/lib/spack/spack/test/conftest.py b/lib/spack/spack/test/conftest.py index 44350dfb50..860732b873 100644 --- a/lib/spack/spack/test/conftest.py +++ b/lib/spack/spack/test/conftest.py @@ -327,7 +327,7 @@ def _populate(mock_db): def _install(spec): s = spack.spec.Spec(spec).concretized() pkg = spack.repo.get(s) - pkg.do_install(fake=True) + pkg.do_install(fake=True, explicit=True) # Transaction used to avoid repeated writes. with mock_db.write_transaction(): diff --git a/lib/spack/spack/test/data/modules/tcl/blacklist_implicits.yaml b/lib/spack/spack/test/data/modules/tcl/blacklist_implicits.yaml new file mode 100644 index 0000000000..4d5fbfb04a --- /dev/null +++ b/lib/spack/spack/test/data/modules/tcl/blacklist_implicits.yaml @@ -0,0 +1,6 @@ +enable: + - tcl +tcl: + blacklist_implicits: true + all: + autoload: 'direct' diff --git a/lib/spack/spack/test/modules/tcl.py b/lib/spack/spack/test/modules/tcl.py index 52415bd791..21e9ae0209 100644 --- a/lib/spack/spack/test/modules/tcl.py +++ b/lib/spack/spack/test/modules/tcl.py @@ -274,3 +274,24 @@ class TestTcl(object): short_description = 'module-whatis "This package updates the context for TCL modulefiles."' # NOQA: ignore=E501 assert short_description in content + + @pytest.mark.regression('4400') + @pytest.mark.db + def test_blacklist_implicits( + self, modulefile_content, module_configuration, database + ): + module_configuration('blacklist_implicits') + + # mpileaks has been installed explicitly when setting up + # the tests database + mpileaks_specs = database.query('mpileaks') + for item in mpileaks_specs: + writer = writer_cls(item) + assert not writer.conf.blacklisted + + # callpath is a dependency of mpileaks, and has been pulled + # in implicitly + callpath_specs = database.query('callpath') + for item in callpath_specs: + writer = writer_cls(item) + assert writer.conf.blacklisted |