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
This commit is contained in:
parent
444e156685
commit
9a637bbd09
@ -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
|
||||
|
@ -620,9 +620,14 @@ def filename(self):
|
||||
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):
|
||||
|
@ -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):
|
||||
|
@ -126,6 +126,7 @@
|
||||
{'type': 'string'},
|
||||
{'type': 'boolean'}
|
||||
]},
|
||||
'arch_folder': {'type': 'boolean'},
|
||||
'prefix_inspections': {
|
||||
'type': 'object',
|
||||
'additionalProperties': False,
|
||||
|
6
lib/spack/spack/test/data/modules/lmod/no_arch.yaml
Normal file
6
lib/spack/spack/test/data/modules/lmod/no_arch.yaml
Normal file
@ -0,0 +1,6 @@
|
||||
enable:
|
||||
- lmod
|
||||
arch_folder: false
|
||||
lmod:
|
||||
core_compilers:
|
||||
- 'clang@3.3'
|
6
lib/spack/spack/test/data/modules/tcl/no_arch.yaml
Normal file
6
lib/spack/spack/test/data/modules/tcl/no_arch.yaml
Normal file
@ -0,0 +1,6 @@
|
||||
enable:
|
||||
- tcl
|
||||
arch_folder: false
|
||||
tcl:
|
||||
projections:
|
||||
all: ''
|
@ -354,3 +354,10 @@ def test_modules_relative_to_view(
|
||||
# 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
|
||||
|
@ -404,3 +404,10 @@ def test_config_backwards_compat(self, mutable_config):
|
||||
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user