summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Becker <becker33@llnl.gov>2021-10-26 13:26:09 -0700
committerGitHub <noreply@github.com>2021-10-26 13:26:09 -0700
commit9a637bbd0980efa657762d0d4dc524942ac096b5 (patch)
tree93097054130e13532a22b3a0462e1b655d37d87c
parent444e156685193ecfe50742d24cad0cf92b1466f6 (diff)
downloadspack-9a637bbd0980efa657762d0d4dc524942ac096b5.tar.gz
spack-9a637bbd0980efa657762d0d4dc524942ac096b5.tar.bz2
spack-9a637bbd0980efa657762d0d4dc524942ac096b5.tar.xz
spack-9a637bbd0980efa657762d0d4dc524942ac096b5.zip
modules: allow user to remove arch dir (#24156)
* allow no arch-dir modules * add tests for modules with no arch * document arch-specific module roots
-rw-r--r--lib/spack/docs/module_file_support.rst12
-rw-r--r--lib/spack/spack/modules/common.py9
-rw-r--r--lib/spack/spack/modules/lmod.py21
-rw-r--r--lib/spack/spack/schema/modules.py1
-rw-r--r--lib/spack/spack/test/data/modules/lmod/no_arch.yaml6
-rw-r--r--lib/spack/spack/test/data/modules/tcl/no_arch.yaml6
-rw-r--r--lib/spack/spack/test/modules/lmod.py7
-rw-r--r--lib/spack/spack/test/modules/tcl.py7
8 files changed, 58 insertions, 11 deletions
diff --git a/lib/spack/docs/module_file_support.rst b/lib/spack/docs/module_file_support.rst
index 960d5ebdaa..c6cbc4b22b 100644
--- a/lib/spack/docs/module_file_support.rst
+++ b/lib/spack/docs/module_file_support.rst
@@ -213,6 +213,18 @@ location). The set ``my_custom_lmod_modules`` will install its lmod
modules to ``/path/to/install/custom/lmod/modules`` (and still install
its tcl modules, if any, to the default location).
+By default, an architecture-specific directory is added to the root
+directory. A module set may override that behavior by setting the
+``arch_folder`` config value to ``False``.
+
+.. code-block:: yaml
+
+ modules:
+ default:
+ roots:
+ tcl: /path/to/install/tcl/modules
+ arch_folder: false
+
Obviously, having multiple module sets install modules to the default
location could be confusing to users of your modules. In the next
section, we will discuss enabling and disabling module types (module
diff --git a/lib/spack/spack/modules/common.py b/lib/spack/spack/modules/common.py
index e09b0f1b6b..ce1b9115cd 100644
--- a/lib/spack/spack/modules/common.py
+++ b/lib/spack/spack/modules/common.py
@@ -620,9 +620,14 @@ class BaseFileLayout(object):
if self.extension:
filename = '{0}.{1}'.format(self.use_name, self.extension)
# Architecture sub-folder
- arch_folder = str(self.spec.architecture)
+ arch_folder_conf = spack.config.get(
+ 'modules:%s:arch_folder' % self.conf.name, True)
+ if arch_folder_conf:
+ # include an arch specific folder between root and filename
+ arch_folder = str(self.spec.architecture)
+ filename = os.path.join(arch_folder, filename)
# Return the absolute path
- return os.path.join(self.dirname(), arch_folder, filename)
+ return os.path.join(self.dirname(), filename)
class BaseContext(tengine.Context):
diff --git a/lib/spack/spack/modules/lmod.py b/lib/spack/spack/modules/lmod.py
index 614c063932..924db9bc98 100644
--- a/lib/spack/spack/modules/lmod.py
+++ b/lib/spack/spack/modules/lmod.py
@@ -222,15 +222,18 @@ class LmodFileLayout(BaseFileLayout):
@property
def arch_dirname(self):
"""Returns the root folder for THIS architecture"""
- arch_folder = '-'.join([
- str(self.spec.platform),
- str(self.spec.os),
- str(self.spec.target.family)
- ])
- return os.path.join(
- self.dirname(), # root for lmod module files
- arch_folder, # architecture relative path
- )
+ # Architecture sub-folder
+ arch_folder_conf = spack.config.get(
+ 'modules:%s:arch_folder' % self.conf.name, True)
+ if arch_folder_conf:
+ # include an arch specific folder between root and filename
+ arch_folder = '-'.join([
+ str(self.spec.platform),
+ str(self.spec.os),
+ str(self.spec.target.family)
+ ])
+ return os.path.join(self.dirname(), arch_folder)
+ return self.dirname()
@property
def filename(self):
diff --git a/lib/spack/spack/schema/modules.py b/lib/spack/spack/schema/modules.py
index d3619b1823..90755f5588 100644
--- a/lib/spack/spack/schema/modules.py
+++ b/lib/spack/spack/schema/modules.py
@@ -126,6 +126,7 @@ module_config_properties = {
{'type': 'string'},
{'type': 'boolean'}
]},
+ 'arch_folder': {'type': 'boolean'},
'prefix_inspections': {
'type': 'object',
'additionalProperties': False,
diff --git a/lib/spack/spack/test/data/modules/lmod/no_arch.yaml b/lib/spack/spack/test/data/modules/lmod/no_arch.yaml
new file mode 100644
index 0000000000..1f10bcb792
--- /dev/null
+++ b/lib/spack/spack/test/data/modules/lmod/no_arch.yaml
@@ -0,0 +1,6 @@
+enable:
+ - lmod
+arch_folder: false
+lmod:
+ core_compilers:
+ - 'clang@3.3' \ No newline at end of file
diff --git a/lib/spack/spack/test/data/modules/tcl/no_arch.yaml b/lib/spack/spack/test/data/modules/tcl/no_arch.yaml
new file mode 100644
index 0000000000..f997251654
--- /dev/null
+++ b/lib/spack/spack/test/data/modules/tcl/no_arch.yaml
@@ -0,0 +1,6 @@
+enable:
+ - tcl
+arch_folder: false
+tcl:
+ projections:
+ all: '' \ No newline at end of file
diff --git a/lib/spack/spack/test/modules/lmod.py b/lib/spack/spack/test/modules/lmod.py
index 861f78c7b8..954c068545 100644
--- a/lib/spack/spack/test/modules/lmod.py
+++ b/lib/spack/spack/test/modules/lmod.py
@@ -354,3 +354,10 @@ class TestLmod(object):
# point to the right one
assert any(expected in line for line in content)
assert not any(spec.prefix in line for line in content)
+
+ def test_modules_no_arch(self, factory, module_configuration):
+ module_configuration('no_arch')
+ module, spec = factory(mpileaks_spec_string)
+ path = module.layout.filename
+
+ assert str(spec.os) not in path
diff --git a/lib/spack/spack/test/modules/tcl.py b/lib/spack/spack/test/modules/tcl.py
index 464d91c278..93930a6a89 100644
--- a/lib/spack/spack/test/modules/tcl.py
+++ b/lib/spack/spack/test/modules/tcl.py
@@ -404,3 +404,10 @@ class TestTcl(object):
assert old_format == new_format
assert old_format == settings['tcl']
+
+ def test_modules_no_arch(self, factory, module_configuration):
+ module_configuration('no_arch')
+ module, spec = factory(mpileaks_spec_string)
+ path = module.layout.filename
+
+ assert str(spec.os) not in path