@@ -415,11 +415,11 @@ def set_alias(self, key, value):
415415 """
416416 raise NotImplementedError
417417
418- def set_as_default (self , module_folder_path , module_version , mod_symlink_paths = [], fake = False ):
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
424424 :param mod_symlink_paths: list of paths in which symlinks to module files must be created
425425 """
@@ -873,34 +873,36 @@ def set_alias(self, key, value):
873873 # quotes are needed, to ensure smooth working of EBDEVEL* modulefiles
874874 return 'set-alias\t %s\t \t %s\n ' % (key , quote_str (value , tcl = True ))
875875
876- def set_as_default (self , module_folder_path , module_version , mod_symlink_paths = [], fake = False ):
876+ def set_as_default (self , module_dir_path , module_version , mod_symlink_paths = None ):
877877 """
878878 Create a .version file inside the package module folder in order to set the default version for TMod
879879
880- :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
881881 :param module_version: module version, e.g. 3.0.4
882882 :param mod_symlink_paths: list of paths in which symlinks to module files must be created
883883 """
884884 txt = self .MODULE_SHEBANG + '\n '
885885 txt += 'set ModulesVersion %s\n ' % module_version
886886
887887 # write the file no matter what
888- dot_version_path = os .path .join (module_folder_path , '.version' )
888+ dot_version_path = os .path .join (module_dir_path , '.version' )
889889 write_file (dot_version_path , txt )
890890
891891 # create symlink to .version file in class module folders
892- if not fake :
893- for mod_symlink_path in mod_symlink_paths :
894- module_name = os .path .basename (module_folder_path )
895- class_module_folder = os .path .join (install_path ('mod' ), mod_symlink_path , module_name )
896- dot_version_link_path = os .path .join (class_module_folder , '.version' )
897- if os .path .islink (dot_version_link_path ):
898- link_target = resolve_path (dot_version_link_path )
899- remove_file (dot_version_link_path )
900- self .log .info ("Removed default version marking from %s." , link_target )
901- elif os .path .exists (dot_version_link_path ):
902- raise EasyBuildError ('Found an unexpected file named .version in dir %s' % class_module_folder )
903- symlink (dot_version_path , dot_version_link_path , use_abspath_source = True )
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 )
904906
905907 def set_environment (self , key , value , relpath = False ):
906908 """
@@ -1294,35 +1296,38 @@ def set_alias(self, key, value):
12941296 # quotes are needed, to ensure smooth working of EBDEVEL* modulefiles
12951297 return 'set_alias("%s", %s)\n ' % (key , quote_str (value ))
12961298
1297- def set_as_default (self , module_folder_path , module_version , mod_symlink_paths = [], fake = False ):
1299+ def set_as_default (self , module_dir_path , module_version , mod_symlink_paths = None ):
12981300 """
12991301 Create a symlink named 'default' inside the package's module folder in order to set the default module version
13001302
1301- :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
13021304 :param module_version: module version, e.g. 3.0.4
13031305 :param mod_symlink_paths: list of paths in which symlinks to module files must be created
13041306 """
1305- def create_default_symlink (module_folder_path ):
1306- 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' )
13071310
13081311 if os .path .islink (default_filepath ):
13091312 link_target = resolve_path (default_filepath )
13101313 remove_file (default_filepath )
13111314 self .log .info ("Removed default version marking from %s." , link_target )
13121315 elif os .path .exists (default_filepath ):
1313- raise EasyBuildError ('Found an unexpected file named default in dir %s' % module_folder_path )
1316+ raise EasyBuildError ('Found an unexpected file named default in dir %s' , module_dir_path )
13141317
13151318 symlink (module_version + self .MODULE_FILE_EXTENSION , default_filepath , use_abspath_source = False )
13161319 self .log .info ("Module default version file written to point to %s" , default_filepath )
13171320
1318- create_default_symlink (module_folder_path )
1321+ create_default_symlink (module_dir_path )
13191322
13201323 # also create symlinks in class module folders
1321- if not fake :
1322- for mod_symlink_path in mod_symlink_paths :
1323- module_name = os .path .basename (module_folder_path )
1324- module_folder_path = os .path .join (install_path ('mod' ), mod_symlink_path , module_name )
1325- create_default_symlink (module_folder_path )
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 )
13261331
13271332 def set_environment (self , key , value , relpath = False ):
13281333 """
0 commit comments