@@ -1469,21 +1469,28 @@ def make_module_extra(self, altroot=None, altversion=None):
1469
1469
for (key , value ) in self .cfg ['modextravars' ].items ():
1470
1470
lines .append (self .module_generator .set_environment (key , value ))
1471
1471
1472
- for (key , value ) in self .cfg ['modextrapaths' ].items ():
1473
- if isinstance (value , str ):
1474
- value = [value ]
1475
- elif not isinstance (value , (tuple , list )):
1476
- raise EasyBuildError ("modextrapaths dict value %s (type: %s) is not a list or tuple" ,
1477
- value , type (value ))
1478
- lines .append (self .module_generator .prepend_paths (key , value , allow_abs = self .cfg ['allow_prepend_abs_path' ]))
1479
-
1480
- for (key , value ) in self .cfg ['modextrapaths_append' ].items ():
1481
- if isinstance (value , str ):
1482
- value = [value ]
1483
- elif not isinstance (value , (tuple , list )):
1484
- raise EasyBuildError ("modextrapaths_append dict value %s (type: %s) is not a list or tuple" ,
1485
- value , type (value ))
1486
- lines .append (self .module_generator .append_paths (key , value , allow_abs = self .cfg ['allow_append_abs_path' ]))
1472
+ for name , prepend in [('modextrapaths' , True ), ('modextrapaths_append' , False )]:
1473
+ allow_abs = self .cfg ['allow_prepend_abs_path' ] if prepend else self .cfg ['allow_append_abs_path' ]
1474
+
1475
+ for (key , value ) in cfg [name ].items ():
1476
+ if not isinstance (value , (tuple , list , dict )):
1477
+ raise EasyBuildError (f"{ name } dict value { value } is not a list or dict" )
1478
+ elif isinstance (value , dict ):
1479
+ if 'paths' not in value or 'delimiter' not in value :
1480
+ raise EasyBuildError (f"{ name } dict value { value } must contain 'path' and 'delimiter'" )
1481
+
1482
+ paths = value ['paths' ]
1483
+ delim = value ['delimiter' ]
1484
+ if not isinstance (paths , (list , str )):
1485
+ raise EasyBuildError ("modextrapaths dict value {value} path must be list or str" )
1486
+ if not isinstance (delim , str ):
1487
+ raise EasyBuildError ("modextrapaths dict value {value} delimiter must be a str" )
1488
+ lines .append (self .module_generator .update_paths (key , value , prepend = prepend , delim = delim ,
1489
+ allow_abs = allow_abs ))
1490
+ else :
1491
+ if isinstance (value , str ):
1492
+ value = [value ]
1493
+ lines .append (self .module_generator .update_paths (key , value , prepend = prepend , allow_abs = allow_abs ))
1487
1494
1488
1495
# add lines to update $PYTHONPATH or $EBPYTHONPREFIXES
1489
1496
lines .extend (self .make_module_pythonpath ())
0 commit comments