@@ -555,180 +555,181 @@ def collect_exts_file_info(self, fetch_files=True, verify_checksums=True):
555555 for ext in exts_list :
556556 if isinstance (ext , str ):
557557 exts_sources .append ({'name' : ext })
558- else :
559- if not isinstance (ext , (list , tuple )) or not ext :
560- raise EasyBuildError ("Extension specified in unknown format (not a string/list/tuple)" )
558+ continue
561559
562- # expected format: (name, version, options (dict))
563- # name and version can use templates, resolved via parent EC
560+ if not isinstance ( ext , ( list , tuple )) or not ext :
561+ raise EasyBuildError ( "Extension specified in unknown format (not a string/list/tuple)" )
564562
565- ext_name = resolve_template (ext [0 ], self .cfg .template_values )
566- if len (ext ) == 1 :
567- exts_sources .append ({'name' : ext_name })
568- else :
569- ext_version = resolve_template (ext [1 ], self .cfg .template_values )
563+ # expected format: (name, version, options (dict))
564+ # name and version can use templates, resolved via parent EC
570565
571- # make sure we grab *raw* dict of default options for extension,
572- # since it may use template values like %(name)s & %(version)s
573- ext_options = copy .deepcopy (self .cfg .get_ref ('exts_default_options' ))
566+ ext_name = resolve_template (ext [0 ], self .cfg .template_values )
567+ if len (ext ) == 1 :
568+ exts_sources .append ({'name' : ext_name })
569+ continue
574570
575- if len (ext ) == 3 :
576- if isinstance (ext_options , dict ):
577- ext_options .update (ext [2 ])
578- else :
579- raise EasyBuildError ("Unexpected type (non-dict) for 3rd element of %s" , ext )
580- elif len (ext ) > 3 :
581- raise EasyBuildError ('Extension specified in unknown format (list/tuple too long)' )
571+ ext_version = resolve_template (ext [1 ], self .cfg .template_values )
582572
583- ext_src = {
584- 'name' : ext_name ,
585- 'version' : ext_version ,
586- 'options' : ext_options ,
587- }
573+ # make sure we grab *raw* dict of default options for extension,
574+ # since it may use template values like %(name)s & %(version)s
575+ ext_options = copy .deepcopy (self .cfg .get_ref ('exts_default_options' ))
588576
589- # if a particular easyblock is specified, make sure it's used
590- # (this is picked up by init_ext_instances)
591- ext_src ['easyblock' ] = ext_options .get ('easyblock' , None )
577+ if len (ext ) == 3 :
578+ if isinstance (ext_options , dict ):
579+ ext_options .update (ext [2 ])
580+ else :
581+ raise EasyBuildError ("Unexpected type (non-dict) for 3rd element of %s" , ext )
582+ elif len (ext ) > 3 :
583+ raise EasyBuildError ('Extension specified in unknown format (list/tuple too long)' )
592584
593- # construct dictionary with template values;
594- # inherited from parent, except for name/version templates which are specific to this extension
595- template_values = copy .deepcopy (self .cfg .template_values )
596- template_values .update (template_constant_dict (ext_src ))
585+ ext_src = {
586+ 'name' : ext_name ,
587+ 'version' : ext_version ,
588+ 'options' : ext_options ,
589+ }
597590
598- # resolve templates in extension options
599- ext_options = resolve_template (ext_options , template_values )
591+ # if a particular easyblock is specified, make sure it's used
592+ # (this is picked up by init_ext_instances)
593+ ext_src ['easyblock' ] = ext_options .get ('easyblock' , None )
600594
601- source_urls = ext_options .get ('source_urls' , [])
602- checksums = ext_options .get ('checksums' , [])
595+ # construct dictionary with template values;
596+ # inherited from parent, except for name/version templates which are specific to this extension
597+ template_values = copy .deepcopy (self .cfg .template_values )
598+ template_values .update (template_constant_dict (ext_src ))
603599
604- download_instructions = ext_options .get ('download_instructions' )
600+ # resolve templates in extension options
601+ ext_options = resolve_template (ext_options , template_values )
605602
606- if ext_options .get ('nosource ' , None ):
607- self . log . debug ( "No sources for extension %s, as indicated by 'nosource'" , ext_name )
603+ source_urls = ext_options .get ('source_urls ' , [])
604+ checksums = ext_options . get ( 'checksums' , [] )
608605
609- elif ext_options .get ('sources' , None ):
610- sources = ext_options ['sources' ]
606+ download_instructions = ext_options .get ('download_instructions' )
611607
612- # only a single source file is supported for extensions currently,
613- # see https://github.com/easybuilders/easybuild-framework/issues/3463
614- if isinstance (sources , list ):
615- if len (sources ) == 1 :
616- source = sources [0 ]
617- else :
618- error_msg = "'sources' spec for %s in exts_list must be single element list. Is: %s"
619- raise EasyBuildError (error_msg , ext_name , sources )
620- else :
621- source = sources
622-
623- # always pass source spec as dict value to fetch_source method,
624- # mostly so we can inject stuff like source URLs
625- if isinstance (source , str ):
626- source = {'filename' : source }
627- elif not isinstance (source , dict ):
628- raise EasyBuildError ("Incorrect value type for source of extension %s: %s" ,
629- ext_name , source )
630-
631- # if no custom source URLs are specified in sources spec,
632- # inject the ones specified for this extension
633- if 'source_urls' not in source :
634- source ['source_urls' ] = source_urls
635-
636- if fetch_files :
637- src = self .fetch_source (source , checksums , extension = True ,
638- download_instructions = download_instructions )
639- ext_src .update ({
640- # keep track of custom extract command (if any)
641- 'extract_cmd' : src ['cmd' ],
642- # copy 'path' entry to 'src' for use with extensions
643- 'src' : src ['path' ],
644- })
608+ if ext_options .get ('nosource' , None ):
609+ self .log .debug ("No sources for extension %s, as indicated by 'nosource'" , ext_name )
645610
611+ elif ext_options .get ('sources' , None ):
612+ sources = ext_options ['sources' ]
613+
614+ # only a single source file is supported for extensions currently,
615+ # see https://github.com/easybuilders/easybuild-framework/issues/3463
616+ if isinstance (sources , list ):
617+ if len (sources ) == 1 :
618+ source = sources [0 ]
646619 else :
647- # use default template for name of source file if none is specified
648- default_source_tmpl = resolve_template ('%(name)s-%(version)s.tar.gz' , template_values )
649-
650- # if no sources are specified via 'sources', fall back to 'source_tmpl'
651- src_fn = ext_options .get ('source_tmpl' )
652- if src_fn is None :
653- src_fn = default_source_tmpl
654- elif not isinstance (src_fn , str ):
655- error_msg = "source_tmpl value must be a string! (found value of type '%s'): %s"
656- raise EasyBuildError (error_msg , type (src_fn ).__name__ , src_fn )
657-
658- if fetch_files :
659- src_path = self .obtain_file (src_fn , extension = True , urls = source_urls ,
660- force_download = force_download ,
661- download_instructions = download_instructions )
662- if src_path :
663- ext_src .update ({'src' : src_path })
664- else :
665- raise EasyBuildError ("Source for extension %s not found." , ext )
620+ error_msg = "'sources' spec for %s in exts_list must be single element list. Is: %s"
621+ raise EasyBuildError (error_msg , ext_name , sources )
622+ else :
623+ source = sources
624+
625+ # always pass source spec as dict value to fetch_source method,
626+ # mostly so we can inject stuff like source URLs
627+ if isinstance (source , str ):
628+ source = {'filename' : source }
629+ elif not isinstance (source , dict ):
630+ raise EasyBuildError ("Incorrect value type for source of extension %s: %s" , ext_name , source )
631+
632+ # if no custom source URLs are specified in sources spec,
633+ # inject the ones specified for this extension
634+ if 'source_urls' not in source :
635+ source ['source_urls' ] = source_urls
636+
637+ if fetch_files :
638+ src = self .fetch_source (source , checksums , extension = True ,
639+ download_instructions = download_instructions )
640+ ext_src .update ({
641+ # keep track of custom extract command (if any)
642+ 'extract_cmd' : src ['cmd' ],
643+ # copy 'path' entry to 'src' for use with extensions
644+ 'src' : src ['path' ],
645+ })
666646
667- # verify checksum for extension sources
668- if verify_checksums and 'src' in ext_src :
669- src_path = ext_src ['src' ]
670- src_fn = os .path .basename (src_path )
647+ else :
648+ # use default template for name of source file if none is specified
649+ default_source_tmpl = resolve_template ('%(name)s-%(version)s.tar.gz' , template_values )
650+
651+ # if no sources are specified via 'sources', fall back to 'source_tmpl'
652+ src_fn = ext_options .get ('source_tmpl' )
653+ if src_fn is None :
654+ src_fn = default_source_tmpl
655+ elif not isinstance (src_fn , str ):
656+ error_msg = "source_tmpl value must be a string! (found value of type '%s'): %s"
657+ raise EasyBuildError (error_msg , type (src_fn ).__name__ , src_fn )
658+
659+ if fetch_files :
660+ src_path = self .obtain_file (src_fn , extension = True , urls = source_urls ,
661+ force_download = force_download ,
662+ download_instructions = download_instructions )
663+ if src_path :
664+ ext_src .update ({'src' : src_path })
665+ else :
666+ raise EasyBuildError ("Source for extension %s not found." , ext )
667+
668+ # verify checksum for extension sources
669+ if verify_checksums and 'src' in ext_src :
670+ src_path = ext_src ['src' ]
671+ src_fn = os .path .basename (src_path )
671672
672- src_checksums = {}
673+ src_checksums = {}
674+ for checksum_type in [CHECKSUM_TYPE_SHA256 ]:
675+ src_checksum = compute_checksum (src_path , checksum_type = checksum_type )
676+ src_checksums [checksum_type ] = src_checksum
677+ self .log .info ("%s checksum for %s: %s" , checksum_type , src_path , src_checksum )
678+
679+ # verify checksum (if provided)
680+ self .log .debug ('Verifying checksums for extension source...' )
681+ fn_checksum = self .get_checksum_for (checksums , filename = src_fn , index = 0 )
682+ if verify_checksum (src_path , fn_checksum , src_checksums ):
683+ self .log .info ('Checksum for extension source %s verified' , src_fn )
684+ elif build_option ('ignore_checksums' ):
685+ print_warning ("Ignoring failing checksum verification for %s" % src_fn )
686+ else :
687+ raise EasyBuildError (
688+ 'Checksum verification for extension source %s failed' , src_fn ,
689+ exit_code = EasyBuildExit .FAIL_CHECKSUM
690+ )
691+
692+ # locate extension patches (if any), and verify checksums
693+ ext_patches = ext_options .get ('patches' , [])
694+ if fetch_files :
695+ ext_patches = self .fetch_patches (patch_specs = ext_patches , extension = True )
696+ else :
697+ ext_patches = [create_patch_info (p ) for p in ext_patches ]
698+
699+ if ext_patches :
700+ self .log .debug ('Found patches for extension %s: %s' , ext_name , ext_patches )
701+ ext_src .update ({'patches' : ext_patches })
702+
703+ if verify_checksums :
704+ computed_checksums = {}
705+ for patch in ext_patches :
706+ patch = patch ['path' ]
707+ computed_checksums [patch ] = {}
673708 for checksum_type in [CHECKSUM_TYPE_SHA256 ]:
674- src_checksum = compute_checksum (src_path , checksum_type = checksum_type )
675- src_checksums [checksum_type ] = src_checksum
676- self .log .info ("%s checksum for %s: %s" , checksum_type , src_path , src_checksum )
677-
678- # verify checksum (if provided)
679- self .log .debug ('Verifying checksums for extension source...' )
680- fn_checksum = self .get_checksum_for (checksums , filename = src_fn , index = 0 )
681- if verify_checksum (src_path , fn_checksum , src_checksums ):
682- self .log .info ('Checksum for extension source %s verified' , src_fn )
709+ checksum = compute_checksum (patch , checksum_type = checksum_type )
710+ computed_checksums [patch ][checksum_type ] = checksum
711+ self .log .info ("%s checksum for %s: %s" , checksum_type , patch , checksum )
712+
713+ # verify checksum (if provided)
714+ self .log .debug ('Verifying checksums for extension patches...' )
715+ for idx , patch in enumerate (ext_patches ):
716+ patch = patch ['path' ]
717+ patch_fn = os .path .basename (patch )
718+
719+ checksum = self .get_checksum_for (checksums , filename = patch_fn , index = idx + 1 )
720+ if verify_checksum (patch , checksum , computed_checksums [patch ]):
721+ self .log .info ('Checksum for extension patch %s verified' , patch_fn )
683722 elif build_option ('ignore_checksums' ):
684- print_warning ("Ignoring failing checksum verification for %s" % src_fn )
723+ print_warning ("Ignoring failing checksum verification for %s" % patch_fn )
685724 else :
686725 raise EasyBuildError (
687- ' Checksum verification for extension source %s failed' , src_fn ,
726+ " Checksum verification for extension patch %s failed" , patch_fn ,
688727 exit_code = EasyBuildExit .FAIL_CHECKSUM
689728 )
729+ else :
730+ self .log .debug ('No patches found for extension %s.' % ext_name )
690731
691- # locate extension patches (if any), and verify checksums
692- ext_patches = ext_options .get ('patches' , [])
693- if fetch_files :
694- ext_patches = self .fetch_patches (patch_specs = ext_patches , extension = True )
695- else :
696- ext_patches = [create_patch_info (p ) for p in ext_patches ]
697-
698- if ext_patches :
699- self .log .debug ('Found patches for extension %s: %s' , ext_name , ext_patches )
700- ext_src .update ({'patches' : ext_patches })
701-
702- if verify_checksums :
703- computed_checksums = {}
704- for patch in ext_patches :
705- patch = patch ['path' ]
706- computed_checksums [patch ] = {}
707- for checksum_type in [CHECKSUM_TYPE_SHA256 ]:
708- checksum = compute_checksum (patch , checksum_type = checksum_type )
709- computed_checksums [patch ][checksum_type ] = checksum
710- self .log .info ("%s checksum for %s: %s" , checksum_type , patch , checksum )
711-
712- # verify checksum (if provided)
713- self .log .debug ('Verifying checksums for extension patches...' )
714- for idx , patch in enumerate (ext_patches ):
715- patch = patch ['path' ]
716- patch_fn = os .path .basename (patch )
717-
718- checksum = self .get_checksum_for (checksums , filename = patch_fn , index = idx + 1 )
719- if verify_checksum (patch , checksum , computed_checksums [patch ]):
720- self .log .info ('Checksum for extension patch %s verified' , patch_fn )
721- elif build_option ('ignore_checksums' ):
722- print_warning ("Ignoring failing checksum verification for %s" % patch_fn )
723- else :
724- raise EasyBuildError (
725- "Checksum verification for extension patch %s failed" , patch_fn ,
726- exit_code = EasyBuildExit .FAIL_CHECKSUM
727- )
728- else :
729- self .log .debug ('No patches found for extension %s.' % ext_name )
730-
731- exts_sources .append (ext_src )
732+ exts_sources .append (ext_src )
732733
733734 return exts_sources
734735
0 commit comments