@@ -415,12 +415,13 @@ def set_alias(self, key, value):
415415 """
416416 raise NotImplementedError
417417
418- def set_as_default (self , module_folder_path , module_version ):
418+ def set_as_default (self , module_dir_path , module_version , mod_symlink_paths = None ):
419419 """
420420 Set generated module as default module
421421
422- :param module_folder_path : module folder path, e.g. $HOME/easybuild/modules/all/Bison
422+ :param module_dir_path : module directory path, e.g. $HOME/easybuild/modules/all/Bison
423423 :param module_version: module version, e.g. 3.0.4
424+ :param mod_symlink_paths: list of paths in which symlinks to module files must be created
424425 """
425426 raise NotImplementedError
426427
@@ -872,18 +873,36 @@ def set_alias(self, key, value):
872873 # quotes are needed, to ensure smooth working of EBDEVEL* modulefiles
873874 return 'set-alias\t %s\t \t %s\n ' % (key , quote_str (value , tcl = True ))
874875
875- def set_as_default (self , module_folder_path , module_version ):
876+ def set_as_default (self , module_dir_path , module_version , mod_symlink_paths = None ):
876877 """
877878 Create a .version file inside the package module folder in order to set the default version for TMod
878879
879- :param module_folder_path : module folder path, e.g. $HOME/easybuild/modules/all/Bison
880+ :param module_dir_path : module directory path, e.g. $HOME/easybuild/modules/all/Bison
880881 :param module_version: module version, e.g. 3.0.4
882+ :param mod_symlink_paths: list of paths in which symlinks to module files must be created
881883 """
882884 txt = self .MODULE_SHEBANG + '\n '
883885 txt += 'set ModulesVersion %s\n ' % module_version
884886
885887 # write the file no matter what
886- write_file (os .path .join (module_folder_path , '.version' ), txt )
888+ dot_version_path = os .path .join (module_dir_path , '.version' )
889+ write_file (dot_version_path , txt )
890+
891+ # create symlink to .version file in class module folders
892+ if mod_symlink_paths is None :
893+ mod_symlink_paths = []
894+
895+ module_dir_name = os .path .basename (module_dir_path )
896+ for mod_symlink_path in mod_symlink_paths :
897+ mod_symlink_dir = os .path .join (install_path ('mod' ), mod_symlink_path , module_dir_name )
898+ dot_version_link_path = os .path .join (mod_symlink_dir , '.version' )
899+ if os .path .islink (dot_version_link_path ):
900+ link_target = resolve_path (dot_version_link_path )
901+ remove_file (dot_version_link_path )
902+ self .log .info ("Removed default version marking from %s." , link_target )
903+ elif os .path .exists (dot_version_link_path ):
904+ raise EasyBuildError ('Found an unexpected file named .version in dir %s' , mod_symlink_dir )
905+ symlink (dot_version_path , dot_version_link_path , use_abspath_source = True )
887906
888907 def set_environment (self , key , value , relpath = False ):
889908 """
@@ -1277,24 +1296,38 @@ def set_alias(self, key, value):
12771296 # quotes are needed, to ensure smooth working of EBDEVEL* modulefiles
12781297 return 'set_alias("%s", %s)\n ' % (key , quote_str (value ))
12791298
1280- def set_as_default (self , module_folder_path , module_version ):
1299+ def set_as_default (self , module_dir_path , module_version , mod_symlink_paths = None ):
12811300 """
12821301 Create a symlink named 'default' inside the package's module folder in order to set the default module version
12831302
1284- :param module_folder_path : module folder path, e.g. $HOME/easybuild/modules/all/Bison
1303+ :param module_dir_path : module directory path, e.g. $HOME/easybuild/modules/all/Bison
12851304 :param module_version: module version, e.g. 3.0.4
1305+ :param mod_symlink_paths: list of paths in which symlinks to module files must be created
12861306 """
1287- default_filepath = os .path .join (module_folder_path , 'default' )
1307+ def create_default_symlink (path ):
1308+ """Helper function to create 'default' symlink in specified directory."""
1309+ default_filepath = os .path .join (path , 'default' )
12881310
1289- if os .path .islink (default_filepath ):
1290- link_target = resolve_path (default_filepath )
1291- remove_file (default_filepath )
1292- self .log .info ("Removed default version marking from %s." , link_target )
1293- elif os .path .exists (default_filepath ):
1294- raise EasyBuildError ('Found an unexpected file named default in dir %s' % module_folder_path )
1311+ if os .path .islink (default_filepath ):
1312+ link_target = resolve_path (default_filepath )
1313+ remove_file (default_filepath )
1314+ self .log .info ("Removed default version marking from %s." , link_target )
1315+ elif os .path .exists (default_filepath ):
1316+ raise EasyBuildError ('Found an unexpected file named default in dir %s' , module_dir_path )
12951317
1296- symlink (module_version + self .MODULE_FILE_EXTENSION , default_filepath , use_abspath_source = False )
1297- self .log .info ("Module default version file written to point to %s" , default_filepath )
1318+ symlink (module_version + self .MODULE_FILE_EXTENSION , default_filepath , use_abspath_source = False )
1319+ self .log .info ("Module default version file written to point to %s" , default_filepath )
1320+
1321+ create_default_symlink (module_dir_path )
1322+
1323+ # also create symlinks in class module folders
1324+ if mod_symlink_paths is None :
1325+ mod_symlink_paths = []
1326+
1327+ for mod_symlink_path in mod_symlink_paths :
1328+ mod_dir_name = os .path .basename (module_dir_path )
1329+ mod_symlink_dir = os .path .join (install_path ('mod' ), mod_symlink_path , mod_dir_name )
1330+ create_default_symlink (mod_symlink_dir )
12981331
12991332 def set_environment (self , key , value , relpath = False ):
13001333 """
0 commit comments