@@ -680,12 +680,11 @@ def collect_exts_file_info(self, fetch_files=True, verify_checksums=True):
680680 'version' : ext_version ,
681681 'options' : ext_options ,
682682 'github_account' : ext_options .get ('github_account' , orig_github_account ),
683+ # if a particular easyblock is specified, make sure it's used
684+ # (this is picked up by init_ext_instances)
685+ 'easyblock' : ext_options .get ('easyblock' , None ),
683686 }
684687
685- # if a particular easyblock is specified, make sure it's used
686- # (this is picked up by init_ext_instances)
687- ext_src ['easyblock' ] = ext_options .get ('easyblock' , None )
688-
689688 # construct dictionary with template values;
690689 # inherited from parent, except for name/version templates which are specific to this extension
691690 template_values = copy .deepcopy (self .cfg .template_values )
@@ -740,13 +739,9 @@ def collect_exts_file_info(self, fetch_files=True, verify_checksums=True):
740739
741740 # if no sources are specified via 'sources', fall back to 'source_tmpl'
742741 src_fn = ext_options .get ('source_tmpl' )
743- is_pypi_source = False
744742 if src_fn is None :
745743 # use default template for name of source file if none is specified
746744 src_fn = '%(name)s-%(version)s.tar.gz'
747- if len (source_urls ) == 1 and PYPI_PKG_URL_PATTERN in source_urls [0 ]:
748- # allow retrying with alternative download_filename
749- is_pypi_source = True
750745 elif not isinstance (src_fn , str ):
751746 error_msg = "source_tmpl value must be a string! (found value of type '%s'): %s"
752747 raise EasyBuildError (error_msg , type (src_fn ).__name__ , src_fn )
@@ -756,17 +751,7 @@ def collect_exts_file_info(self, fetch_files=True, verify_checksums=True):
756751 if fetch_files :
757752 src_path = self .obtain_file (src_fn , extension = True , urls = source_urls ,
758753 force_download = force_download ,
759- download_instructions = download_instructions ,
760- warning_only = is_pypi_source )
761- if not src_path and is_pypi_source :
762- # retry with alternative download_filename
763- alt_name = resolve_template ('%(name)s' , template_values ).replace ("-" , "_" )
764- src_version = resolve_template ('%(version)s' , template_values )
765- alt_download_fn = f'{ alt_name } -{ src_version } .tar.gz'
766- src_path = self .obtain_file (src_fn , extension = True , urls = source_urls ,
767- force_download = force_download ,
768- download_instructions = download_instructions ,
769- download_filename = alt_download_fn )
754+ download_instructions = download_instructions )
770755 if src_path :
771756 ext_src .update ({'src' : src_path })
772757 else :
@@ -1027,15 +1012,31 @@ def obtain_file(self, filename, extension=False, urls=None, download_filename=No
10271012 target_path = os .path .join (targetdir , "extensions" , filename )
10281013 else :
10291014 target_path = os .path .join (targetdir , filename )
1030- downloaded , failed_urls = self .download_file (target_path , download_filename = download_filename or filename ,
1031- urls = source_urls ,
1015+ if download_filename is None :
1016+ download_filename = filename
1017+ downloaded , failed_urls = self .download_file (target_path , download_filename , urls = source_urls ,
10321018 # Only log when extensions have explicit URLs
10331019 log_url_in_dry_run = extension and urls )
10341020 if downloaded :
10351021 return target_path
1036-
10371022 failedpaths .extend (failed_urls )
10381023
1024+ # Usual PYPI sources have a format of '<name>-version.ext', with '<name>' has dashes replaced by underscores
1025+ num_dashes = download_filename .count ('-' )
1026+ if num_dashes >= 2 and any (PYPI_PKG_URL_PATTERN in url for url in source_urls ):
1027+ # Last dash is the separator between name and version
1028+ alt_download_filename = download_filename .replace ('-' , '_' , num_dashes - 1 )
1029+ self .log .warning ("Could not download %s (%s) from any of %s.\n "
1030+ "Retrying with alternative download filename '%s' as it looks like a PYPI source." ,
1031+ filename , download_filename , ', ' .join (source_urls ), alt_download_filename )
1032+ # retry with alternative download_filename
1033+ downloaded , failed_urls = self .download_file (target_path , alt_download_filename , urls = source_urls ,
1034+ # Only log when extensions have explicit URLs
1035+ log_url_in_dry_run = extension and urls )
1036+ if downloaded :
1037+ return target_path
1038+ failedpaths .extend (failed_urls )
1039+
10391040 if self .dry_run :
10401041 self .dry_run_msg (" * %s (MISSING)" , filename )
10411042 return filename
@@ -2829,7 +2830,7 @@ def check_checksums_for(self, ent, sub='', source_cnt=None):
28292830 # if the filename is a dict, the actual source file name is the "filename" element
28302831 if isinstance (fn , dict ):
28312832 fn = fn ["filename" ]
2832- if fn in checksums_from_json . keys () :
2833+ if fn in checksums_from_json :
28332834 checksums += [checksums_from_json [fn ]]
28342835
28352836 if source_cnt is None :
0 commit comments