@@ -106,22 +106,22 @@ class ModulesSystem:
106
106
module_map = fields .TypedField (types .Dict [str , types .List [str ]])
107
107
108
108
@classmethod
109
- def create (cls , modules_kind = None ):
109
+ def create (cls , modules_kind = None , module_resolution = True ):
110
110
getlogger ().debug (f'Initializing modules system { modules_kind !r} ' )
111
111
if modules_kind is None or modules_kind == 'nomod' :
112
112
return ModulesSystem (NoModImpl ())
113
113
elif modules_kind == 'tmod31' :
114
- return ModulesSystem (TMod31Impl ())
114
+ return ModulesSystem (TMod31Impl (module_resolution ))
115
115
elif modules_kind == 'tmod' :
116
- return ModulesSystem (TModImpl ())
116
+ return ModulesSystem (TModImpl (module_resolution ))
117
117
elif modules_kind == 'tmod32' :
118
- return ModulesSystem (TModImpl ())
118
+ return ModulesSystem (TModImpl (module_resolution ))
119
119
elif modules_kind == 'tmod4' :
120
- return ModulesSystem (TMod4Impl ())
120
+ return ModulesSystem (TMod4Impl (module_resolution ))
121
121
elif modules_kind == 'lmod' :
122
- return ModulesSystem (LModImpl ())
122
+ return ModulesSystem (LModImpl (module_resolution ))
123
123
elif modules_kind == 'spack' :
124
- return ModulesSystem (SpackImpl ())
124
+ return ModulesSystem (SpackImpl (module_resolution ))
125
125
else :
126
126
raise ConfigError ('unknown module system: %s' % modules_kind )
127
127
@@ -585,7 +585,12 @@ class TModImpl(ModulesSystemImpl):
585
585
586
586
MIN_VERSION = (3 , 2 )
587
587
588
- def __init__ (self ):
588
+ def __init__ (self , module_resolution = True ):
589
+ if not module_resolution :
590
+ # The module system may not be available locally
591
+ self ._version = None
592
+ return
593
+
589
594
# Try to figure out if we are indeed using the TCL version
590
595
try :
591
596
completed = osext .run_command ('modulecmd -V' )
@@ -717,7 +722,14 @@ class TMod31Impl(TModImpl):
717
722
718
723
MIN_VERSION = (3 , 1 )
719
724
720
- def __init__ (self ):
725
+ def __init__ (self , module_resolution = True ):
726
+ self ._version = None
727
+ self ._command = None
728
+
729
+ if not module_resolution :
730
+ # The module system may not be available locally
731
+ return
732
+
721
733
# Try to figure out if we are indeed using the TCL version
722
734
try :
723
735
modulecmd = os .getenv ('MODULESHOME' )
@@ -792,7 +804,13 @@ class TMod4Impl(TModImpl):
792
804
793
805
MIN_VERSION = (4 , 1 )
794
806
795
- def __init__ (self ):
807
+ def __init__ (self , module_resolution = True ):
808
+ self ._version = None
809
+ self ._extra_module_paths = []
810
+ if not module_resolution :
811
+ # The module system may not be available locally
812
+ return
813
+
796
814
try :
797
815
completed = osext .run_command (self .modulecmd ('-V' ), check = True )
798
816
except OSError as e :
@@ -915,7 +933,13 @@ def searchpath_remove(self, *dirs):
915
933
class LModImpl (TMod4Impl ):
916
934
'''Module system for Lmod (Tcl/Lua).'''
917
935
918
- def __init__ (self ):
936
+ def __init__ (self , module_resolution = True ):
937
+ self ._extra_module_paths = []
938
+ self ._version = None
939
+ if not module_resolution :
940
+ # The module system may not be available locally
941
+ return
942
+
919
943
# Try to figure out if we are indeed using LMOD
920
944
self ._lmod_cmd = os .getenv ('LMOD_CMD' )
921
945
if self ._lmod_cmd is None :
@@ -945,8 +969,6 @@ def __init__(self):
945
969
raise ConfigError ('Python is not supported by '
946
970
'this Lmod installation' )
947
971
948
- self ._extra_module_paths = []
949
-
950
972
def name (self ):
951
973
return 'lmod'
952
974
@@ -1094,7 +1116,14 @@ class SpackImpl(ModulesSystemImpl):
1094
1116
1095
1117
'''
1096
1118
1097
- def __init__ (self ):
1119
+ def __init__ (self , module_resolution = True ):
1120
+ self ._name_format = '{name}/{version}-{hash}'
1121
+ self ._version = None
1122
+
1123
+ if not module_resolution :
1124
+ # The module system may not be available locally
1125
+ return
1126
+
1098
1127
# Try to figure out if we are indeed using the TCL version
1099
1128
try :
1100
1129
completed = osext .run_command ('spack -V' )
@@ -1103,7 +1132,6 @@ def __init__(self):
1103
1132
'could not find a sane Spack installation' ) from e
1104
1133
1105
1134
self ._version = completed .stdout .strip ()
1106
- self ._name_format = '{name}/{version}-{hash}'
1107
1135
1108
1136
def name (self ):
1109
1137
return 'spack'
0 commit comments