Disable module generation during bootstrapping
This commit is contained in:
parent
c309adb4b3
commit
4033cc0250
@ -25,6 +25,7 @@
|
|||||||
import spack.config
|
import spack.config
|
||||||
import spack.environment
|
import spack.environment
|
||||||
import spack.main
|
import spack.main
|
||||||
|
import spack.modules
|
||||||
import spack.paths
|
import spack.paths
|
||||||
import spack.repo
|
import spack.repo
|
||||||
import spack.spec
|
import spack.spec
|
||||||
@ -430,6 +431,7 @@ def ensure_bootstrap_configuration():
|
|||||||
# and builtin but accounting for platform specific scopes
|
# and builtin but accounting for platform specific scopes
|
||||||
config_scopes = _bootstrap_config_scopes()
|
config_scopes = _bootstrap_config_scopes()
|
||||||
with spack.config.use_configuration(*config_scopes):
|
with spack.config.use_configuration(*config_scopes):
|
||||||
|
with spack.modules.disable_modules():
|
||||||
with spack_python_interpreter():
|
with spack_python_interpreter():
|
||||||
yield
|
yield
|
||||||
|
|
||||||
|
@ -750,8 +750,9 @@ def override(path_or_scope, value=None):
|
|||||||
config.push_scope(overrides)
|
config.push_scope(overrides)
|
||||||
config.set(path_or_scope, value, scope=scope_name)
|
config.set(path_or_scope, value, scope=scope_name)
|
||||||
|
|
||||||
|
try:
|
||||||
yield config
|
yield config
|
||||||
|
finally:
|
||||||
scope = config.remove_scope(overrides.name)
|
scope = config.remove_scope(overrides.name)
|
||||||
assert scope is overrides
|
assert scope is overrides
|
||||||
|
|
||||||
|
@ -9,12 +9,14 @@
|
|||||||
|
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
|
||||||
|
from .common import disable_modules
|
||||||
from .lmod import LmodModulefileWriter
|
from .lmod import LmodModulefileWriter
|
||||||
from .tcl import TclModulefileWriter
|
from .tcl import TclModulefileWriter
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'TclModulefileWriter',
|
'TclModulefileWriter',
|
||||||
'LmodModulefileWriter'
|
'LmodModulefileWriter',
|
||||||
|
'disable_modules'
|
||||||
]
|
]
|
||||||
|
|
||||||
module_types = {
|
module_types = {
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
module type.
|
module type.
|
||||||
"""
|
"""
|
||||||
import collections
|
import collections
|
||||||
|
import contextlib
|
||||||
import copy
|
import copy
|
||||||
import datetime
|
import datetime
|
||||||
import inspect
|
import inspect
|
||||||
@ -41,6 +42,7 @@
|
|||||||
from llnl.util.lang import dedupe
|
from llnl.util.lang import dedupe
|
||||||
|
|
||||||
import spack.build_environment as build_environment
|
import spack.build_environment as build_environment
|
||||||
|
import spack.config
|
||||||
import spack.environment as ev
|
import spack.environment as ev
|
||||||
import spack.error
|
import spack.error
|
||||||
import spack.paths
|
import spack.paths
|
||||||
@ -905,6 +907,19 @@ def remove(self):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@contextlib.contextmanager
|
||||||
|
def disable_modules():
|
||||||
|
"""Disable the generation of modulefiles within the context manager."""
|
||||||
|
data = {
|
||||||
|
'modules:': {
|
||||||
|
'enable': []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
disable_scope = spack.config.InternalConfigScope('disable_modules', data=data)
|
||||||
|
with spack.config.override(disable_scope):
|
||||||
|
yield
|
||||||
|
|
||||||
|
|
||||||
class ModulesError(spack.error.SpackError):
|
class ModulesError(spack.error.SpackError):
|
||||||
"""Base error for modules."""
|
"""Base error for modules."""
|
||||||
|
|
||||||
|
@ -64,3 +64,17 @@ def test_bootstrap_deactivates_environments(active_mock_environment):
|
|||||||
with spack.bootstrap.ensure_bootstrap_configuration():
|
with spack.bootstrap.ensure_bootstrap_configuration():
|
||||||
assert spack.environment.active_environment() is None
|
assert spack.environment.active_environment() is None
|
||||||
assert spack.environment.active_environment() == active_mock_environment
|
assert spack.environment.active_environment() == active_mock_environment
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.regression('25805')
|
||||||
|
def test_bootstrap_disables_modulefile_generation(mutable_config):
|
||||||
|
# Be sure to enable both lmod and tcl in modules.yaml
|
||||||
|
spack.config.set('modules:enable', ['tcl', 'lmod'])
|
||||||
|
|
||||||
|
assert 'tcl' in spack.config.get('modules:enable')
|
||||||
|
assert 'lmod' in spack.config.get('modules:enable')
|
||||||
|
with spack.bootstrap.ensure_bootstrap_configuration():
|
||||||
|
assert 'tcl' not in spack.config.get('modules:enable')
|
||||||
|
assert 'lmod' not in spack.config.get('modules:enable')
|
||||||
|
assert 'tcl' in spack.config.get('modules:enable')
|
||||||
|
assert 'lmod' in spack.config.get('modules:enable')
|
||||||
|
Loading…
Reference in New Issue
Block a user