Skip to content

Commit 03e73b9

Browse files
committed
build with parametrized compression levels
1 parent aae61ba commit 03e73b9

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

generate_winpython_distros313_wheel.bat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ set my_release=
1414
set my_release_level=
1515

1616
rem list of installers to create separated per dot: False=none, .zip=zip, .7z=.7z, 7zip=auto-extractible 7z
17-
set my_create_installer=7zip.7z.zip
18-
set my_create_installer=.7z
17+
set my_create_installer=7zip-mx5.7z-mx7.zip
18+
set my_create_installer=.7z-mx7
1919

2020
set my_preclear_build_directory=Yes
2121

make.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -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

338339
if __name__ == "__main__":
339340
# DO create only one Winpython distribution at a time

0 commit comments

Comments
 (0)