Skip to content

move zip logic out of make.py #1666

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions generate_a_winpython_distro.bat
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ call %my_buildenv%\scripts\env.bat

REM Create basic build infrastructure
echo "(%date% %time%) Create basic build infrastructure">>%my_archive_log%
python.exe -c "from make import *;make_all(%my_release%, '%my_release_level%', basedir_wpy=r'%my_WINPYDIRBASE%', verbose=True, flavor='%my_flavor%', install_options=r'%my_install_options%', find_links=r'%my_find_links%', source_dirs=r'%my_source_dirs%', toolsdirs=r'%my_toolsdirs%', create_installer='False', python_target_release='%my_python_target_release%')">>%my_archive_log%
python.exe -c "from make import *;make_all(%my_release%, '%my_release_level%', basedir_wpy=r'%my_WINPYDIRBASE%', verbose=True, flavor='%my_flavor%', install_options=r'%my_install_options%', find_links=r'%my_find_links%', source_dirs=r'%my_source_dirs%', toolsdirs=r'%my_toolsdirs%', create_installer='False')">>%my_archive_log%

REM Check infrastructure is in place
echo "(%date% %time%) Check infrastructure">>%my_archive_log%
Expand All @@ -70,7 +70,7 @@ set WINPYDIRBASE=%my_WINPYDIRBASE%
if not exist %my_WINPYDIRBASE%\scripts\env.bat (
@echo off
echo as %my_WINPYDIRBASE%\scripts\env.bat does not exist
echo please check and correct my_python_target_release=%my_python_target_release%
echo please check and correct:
echo my_arch=%my_arch%
echo my_python_target_release=%my_python_target_release%
echo my_release=%my_release%
Expand Down Expand Up @@ -206,12 +206,19 @@ call %my_WINPYDIRBASE%\scripts\env.bat

REM Generate changelog and binaries
echo "(%date% %time%) Generate changelog and binaries">>%my_archive_log%
set path=%my_original_path%
cd /D %~dp0
call %my_buildenv%\scripts\env.bat

python.exe -c "from make import *;make_all(%my_release%, '%my_release_level%', basedir_wpy=r'%my_WINPYDIRBASE%', verbose=True, flavor='%my_flavor%', install_options=r'%my_install_options%', find_links=r'%my_find_links%', source_dirs=r'%my_source_dirs%', create_installer='%my_create_installer%', rebuild=False, python_target_release='%my_python_target_release%')" >> %my_archive_log%
rem markdowm and markdown diff
set mdn=WinPython%my_flavor%-%my_arch%bit-%WINPYVER2%.md
%target_python_exe% -m wppm -md>%my_basedir%\bu%my_flavor%\%mdn%
copy/y %my_basedir%\bu%my_flavor%\%mdn% %~dp0changelogs\%mdn%

set out=WinPython%my_flavor%-%my_arch%bit-%WINPYVER2%_History.md
%target_python_exe% -c "from wppm import diff ;a=(diff.compare_package_indexes(r'%WINPYVER2%', searchdir=r'%~dp0changelogs',flavor=r'%my_flavor%',architecture=%my_arch%));f=open(r'%my_basedir%\bu%my_flavor%\%out%','w', encoding='utf-8');f.write(a);f.close()"
copy/y %my_basedir%\bu%my_flavor%\%out% %~dp0changelogs\%out%

rem compress
set stem=WinPython%my_arch%-%WINPYVER2%%my_flavor%
%target_python_exe% -c "from wppm import utils;utils.command_installer_7zip(r'%my_WINPYDIRBASE%', r'%my_WINPYDIRBASE%\..',r'%stem%', r'%my_create_installer%')"

echo -------------------------------------- >>%my_archive_log%
echo "(%date% %time%) END OF CREATION">>%my_archive_log%
Expand Down
21 changes: 0 additions & 21 deletions make.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,24 +119,6 @@ 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", compression= "mx5"):
"""Creates a WinPython installer using 7-Zip: "exe", "7z", "zip")"""
self._print_action(f"Creating WinPython installer ({installer_type})")
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)
if installer_type not in ["exe", "7z", "zip"]:
return
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'"{utils.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)
except subprocess.CalledProcessError as e:
print(f"Error executing 7-Zip script: {e}", file=sys.stderr)

def _print_action(self, text: str):
"""Prints an action message with progress indicator."""
if self.verbose:
Expand Down Expand Up @@ -254,9 +236,6 @@ def make_all(build_number: int, release_level: str, basedir_wpy: Path = None,

builder.build(rebuild=rebuild, winpy_dir=winpy_dir)

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
Expand Down