From 03e73b94bfb1d1bcac2819ed01c1eaa9f4119b22 Mon Sep 17 00:00:00 2001 From: stonebig Date: Wed, 28 May 2025 18:45:55 +0200 Subject: [PATCH] build with parametrized compression levels --- generate_winpython_distros313_wheel.bat | 4 ++-- make.py | 23 ++++++++++++----------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/generate_winpython_distros313_wheel.bat b/generate_winpython_distros313_wheel.bat index 9ae54ff3..02edeb99 100644 --- a/generate_winpython_distros313_wheel.bat +++ b/generate_winpython_distros313_wheel.bat @@ -14,8 +14,8 @@ set my_release= set my_release_level= rem list of installers to create separated per dot: False=none, .zip=zip, .7z=.7z, 7zip=auto-extractible 7z -set my_create_installer=7zip.7z.zip -set my_create_installer=.7z +set my_create_installer=7zip-mx5.7z-mx7.zip +set my_create_installer=.7z-mx7 set my_preclear_build_directory=Yes diff --git a/make.py b/make.py index a23d719d..1445cadc 100644 --- a/make.py +++ b/make.py @@ -146,17 +146,18 @@ def architecture_bits(self) -> int: """Returns the architecture (32 or 64 bits) of the distribution.""" return self.distribution.architecture if self.distribution else 64 - def create_installer_7zip(self, installer_type: str = ".exe"): - """Creates a WinPython installer using 7-Zip: ".exe", ".7z", ".zip")""" + def create_installer_7zip(self, installer_type: str = "exe", compression= "mx5"): + """Creates a WinPython installer using 7-Zip: "exe", "7z", "zip")""" self._print_action(f"Creating WinPython installer ({installer_type})") - if installer_type not in [".exe", ".7z", ".zip"]: - raise RuntimeError("installer_type {installer_type} is undefined") + if installer_type not in ["exe", "7z", "zip"]: + return DISTDIR = self.winpython_directory filename_stem = f"Winpython{self.architecture_bits}-{self.python_full_version}.{self.build_number}{self.flavor}{self.release_level}" - fullfilename = DISTDIR.parent / (filename_stem + installer_type) - sfx_option = "-sfx7z.sfx" if installer_type == ".exe" else "" - zip_option = "-tzip" if installer_type == ".zip" else "" - command = f'"{find_7zip_executable()}" {zip_option} -mx5 a "{fullfilename}" "{DISTDIR}" {sfx_option}' + fullfilename = DISTDIR.parent / (filename_stem + "." + installer_type) + sfx_option = "-sfx7z.sfx" if installer_type == "exe" else "" + zip_option = "-tzip" if installer_type == "zip" else "" + compress_level = "mx5" if compression == "" else compression + command = f'"{find_7zip_executable()}" {zip_option} -{compress_level} a "{fullfilename}" "{DISTDIR}" {sfx_option}' print(f'Executing 7-Zip script: "{command}"') try: 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 builder.build(rebuild=rebuild, requirements_files_list=requirements_files_list, winpy_dirname=winpython_dirname) - for installer_type in [".zip", ".7z", ".exe"]: - if installer_type in create_installer.lower().replace("7zip",".exe"): - builder.create_installer_7zip(installer_type) + for commmand in create_installer.lower().replace("7zip",".exe").split('.'): + installer_type, compression = (commmand + "-").split("-")[:2] + builder.create_installer_7zip(installer_type, compression) if __name__ == "__main__": # DO create only one Winpython distribution at a time