@@ -2810,7 +2810,7 @@ def reproducible_filter(tarinfo):
28102810 tarinfo .uname = tarinfo .gname = ""
28112811 return tarinfo
28122812
2813- compression = {
2813+ ext_compression_map = {
28142814 # taken from EXTRACT_CMDS
28152815 '.gtgz' : 'gz' ,
28162816 '.tar.gz' : 'gz' ,
@@ -2823,47 +2823,49 @@ def reproducible_filter(tarinfo):
28232823 '.txz' : 'xz' ,
28242824 '.tar' : '' ,
28252825 }
2826- reproducible_compression = ["" , "xz" ]
2827- default_ext = " .tar.xz"
2826+ reproducible_compression = ['' , 'xz' ]
2827+ default_ext = ' .tar.xz'
28282828
28292829 if archive_file is None :
28302830 archive_file = os .path .basename (source_dir ) + default_ext
28312831
28322832 try :
28332833 archive_ext = find_extension (archive_file )
28342834 except EasyBuildError :
2835- if "." in archive_file :
2835+ if '.' in archive_file :
28362836 # archive filename has unknown extension (set for raise)
2837- archive_ext = ""
2837+ archive_ext = ''
28382838 else :
28392839 # archive filename has no extension, use default one
28402840 archive_ext = default_ext
28412841 archive_file += archive_ext
28422842
2843- if archive_ext not in compression :
2843+ if archive_ext not in ext_compression_map :
28442844 # archive filename has unsupported extension
2845+ supported_exts = ', ' .join (ext_compression_map )
28452846 raise EasyBuildError (
2846- f"Unsupported archive format: { archive_file } . Supported tarball extensions: { ', ' . join ( compression ) } "
2847+ f"Unsupported archive format: { archive_file } . Supported tarball extensions: { supported_exts } "
28472848 )
2848- _log .debug (f"Archive extension and compression: { archive_ext } in { compression [archive_ext ]} " )
2849+ compression = ext_compression_map [archive_ext ]
2850+ _log .debug (f"Archive extension and compression: { archive_ext } in { compression } " )
28492851
28502852 archive_path = archive_file if archive_dir is None else os .path .join (archive_dir , archive_file )
28512853
2852- archive = {
2854+ archive_specs = {
28532855 'name' : archive_path ,
2854- 'mode' : f"w:{ compression [ archive_ext ] } " ,
2856+ 'mode' : f"w:{ compression } " ,
28552857 'format' : tarfile .GNU_FORMAT ,
28562858 'encoding' : "utf-8" ,
28572859 }
28582860
28592861 if reproducible :
2860- if compression [ archive_ext ] == "xz" :
2862+ if compression == 'xz' :
28612863 # ensure a consistent compression level in reproducible tarballs with XZ
2862- archive [ " preset" ] = 6
2863- elif compression [ archive_ext ] not in reproducible_compression :
2864+ archive_specs [ ' preset' ] = 6
2865+ elif compression not in reproducible_compression :
28642866 # requested archive compression cannot be made reproducible
28652867 print_warning (
2866- f"Requested reproducible archive with unsupported file compression ({ compression [ archive_ext ] } ). "
2868+ f"Can not create reproducible archive due to unsupported file compression ({ compression } ). "
28672869 "Please use XZ instead."
28682870 )
28692871 reproducible = False
@@ -2884,7 +2886,7 @@ def reproducible_filter(tarinfo):
28842886 source_files .extend ([str (filepath ) for filepath in pathlib .Path (source_dir ).glob ("**/*" )])
28852887 source_files .sort () # independent of locale
28862888
2887- with tarfile .open (** archive ) as tar_archive :
2889+ with tarfile .open (** archive_specs ) as tar_archive :
28882890 for filepath in source_files :
28892891 # archive with target directory in its top level, remove any prefix in path
28902892 file_name = os .path .relpath (filepath , start = os .path .dirname (source_dir ))
0 commit comments