@@ -146,17 +146,18 @@ def architecture_bits(self) -> int:
146146 """Returns the architecture (32 or 64 bits) of the distribution."""
147147 return self .distribution .architecture if self .distribution else 64
148148
149- def create_installer_7zip (self , installer_type : str = ". exe" ):
150- """Creates a WinPython installer using 7-Zip: ". exe", ". 7z", ". zip")"""
149+ def create_installer_7zip (self , installer_type : str = "exe" , compression = "mx5 " ):
150+ """Creates a WinPython installer using 7-Zip: "exe", "7z", "zip")"""
151151 self ._print_action (f"Creating WinPython installer ({ installer_type } )" )
152- if installer_type not in [". exe" , ". 7z" , ". zip" ]:
153- raise RuntimeError ( "installer_type {installer_type} is undefined" )
152+ if installer_type not in ["exe" , "7z" , "zip" ]:
153+ return
154154 DISTDIR = self .winpython_directory
155155 filename_stem = f"Winpython{ self .architecture_bits } -{ self .python_full_version } .{ self .build_number } { self .flavor } { self .release_level } "
156- fullfilename = DISTDIR .parent / (filename_stem + installer_type )
157- sfx_option = "-sfx7z.sfx" if installer_type == ".exe" else ""
158- zip_option = "-tzip" if installer_type == ".zip" else ""
159- command = f'"{ find_7zip_executable ()} " { zip_option } -mx5 a "{ fullfilename } " "{ DISTDIR } " { sfx_option } '
156+ fullfilename = DISTDIR .parent / (filename_stem + "." + installer_type )
157+ sfx_option = "-sfx7z.sfx" if installer_type == "exe" else ""
158+ zip_option = "-tzip" if installer_type == "zip" else ""
159+ compress_level = "mx5" if compression == "" else compression
160+ command = f'"{ find_7zip_executable ()} " { zip_option } -{ compress_level } a "{ fullfilename } " "{ DISTDIR } " { sfx_option } '
160161 print (f'Executing 7-Zip script: "{ command } "' )
161162 try :
162163 subprocess .run (command , shell = True , check = True , stderr = sys .stderr , stdout = sys .stderr )
@@ -331,9 +332,9 @@ def make_all(build_number: int, release_level: str, pyver: str, architecture: in
331332
332333 builder .build (rebuild = rebuild , requirements_files_list = requirements_files_list , winpy_dirname = winpython_dirname )
333334
334- for installer_type in [ ".zip" , ".7z" , ".exe" ] :
335- if installer_type in create_installer . lower (). replace ( "7zip" , ".exe" ):
336- builder .create_installer_7zip (installer_type )
335+ for commmand in create_installer . lower (). replace ( "7zip" , ".exe" ). split ( '.' ) :
336+ installer_type , compression = ( commmand + "-" ). split ( "-" )[: 2 ]
337+ builder .create_installer_7zip (installer_type , compression )
337338
338339if __name__ == "__main__" :
339340 # DO create only one Winpython distribution at a time
0 commit comments