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
|
modules to ``/path/to/install/custom/lmod/modules`` (and still install
|
||||||
its tcl modules, if any, to the default location).
|
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
|
Obviously, having multiple module sets install modules to the default
|
||||||
location could be confusing to users of your modules. In the next
|
location could be confusing to users of your modules. In the next
|
||||||
section, we will discuss enabling and disabling module types (module
|
section, we will discuss enabling and disabling module types (module
|
||||||
|
@ -620,9 +620,14 @@ def filename(self):
|
|||||||
if self.extension:
|
if self.extension:
|
||||||
filename = '{0}.{1}'.format(self.use_name, self.extension)
|
filename = '{0}.{1}'.format(self.use_name, self.extension)
|
||||||
# Architecture sub-folder
|
# 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 the absolute path
|
||||||
return os.path.join(self.dirname(), arch_folder, filename)
|
return os.path.join(self.dirname(), filename)
|
||||||
|
|
||||||
|
|
||||||
class BaseContext(tengine.Context):
|
class BaseContext(tengine.Context):
|
||||||
|
@ -222,15 +222,18 @@ class LmodFileLayout(BaseFileLayout):
|
|||||||
@property
|
@property
|
||||||
def arch_dirname(self):
|
def arch_dirname(self):
|
||||||
"""Returns the root folder for THIS architecture"""
|
"""Returns the root folder for THIS architecture"""
|
||||||
arch_folder = '-'.join([
|
# Architecture sub-folder
|
||||||
str(self.spec.platform),
|
arch_folder_conf = spack.config.get(
|
||||||
str(self.spec.os),
|
'modules:%s:arch_folder' % self.conf.name, True)
|
||||||
str(self.spec.target.family)
|
if arch_folder_conf:
|
||||||
])
|
# include an arch specific folder between root and filename
|
||||||
return os.path.join(
|
arch_folder = '-'.join([
|
||||||
self.dirname(), # root for lmod module files
|
str(self.spec.platform),
|
||||||
arch_folder, # architecture relative path
|
str(self.spec.os),
|
||||||
)
|
str(self.spec.target.family)
|
||||||
|
])
|
||||||
|
return os.path.join(self.dirname(), arch_folder)
|
||||||
|
return self.dirname()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def filename(self):
|
def filename(self):
|
||||||
|
@ -126,6 +126,7 @@
|
|||||||
{'type': 'string'},
|
{'type': 'string'},
|
||||||
{'type': 'boolean'}
|
{'type': 'boolean'}
|
||||||
]},
|
]},
|
||||||
|
'arch_folder': {'type': 'boolean'},
|
||||||
'prefix_inspections': {
|
'prefix_inspections': {
|
||||||
'type': 'object',
|
'type': 'object',
|
||||||
'additionalProperties': False,
|
'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
|
# point to the right one
|
||||||
assert any(expected in line for line in content)
|
assert any(expected in line for line in content)
|
||||||
assert not any(spec.prefix 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 == new_format
|
||||||
assert old_format == settings['tcl']
|
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