Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 07e29be

Browse files
committed
move zip logic out of make.py
1 parent 399c64e commit 07e29be

File tree

2 files changed

+13
-27
lines changed

2 files changed

+13
-27
lines changed

generate_a_winpython_distro.bat

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ call %my_buildenv%\scripts\env.bat
6161

6262
REM Create basic build infrastructure
6363
echo "(%date% %time%) Create basic build infrastructure">>%my_archive_log%
64-
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%
64+
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%
6565

6666
REM Check infrastructure is in place
6767
echo "(%date% %time%) Check infrastructure">>%my_archive_log%
@@ -70,7 +70,7 @@ set WINPYDIRBASE=%my_WINPYDIRBASE%
7070
if not exist %my_WINPYDIRBASE%\scripts\env.bat (
7171
@echo off
7272
echo as %my_WINPYDIRBASE%\scripts\env.bat does not exist
73-
echo please check and correct my_python_target_release=%my_python_target_release%
73+
echo please check and correct:
7474
echo my_arch=%my_arch%
7575
echo my_python_target_release=%my_python_target_release%
7676
echo my_release=%my_release%
@@ -206,12 +206,19 @@ call %my_WINPYDIRBASE%\scripts\env.bat
206206

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

213-
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%
210+
rem markdowm and markdown diff
211+
set mdn=WinPython%my_flavor%-%my_arch%bit-%WINPYVER2%.md
212+
%target_python_exe% -m wppm -md>%my_basedir%\bu%my_flavor%\%mdn%
213+
copy/y %my_basedir%\bu%my_flavor%\%mdn% %~dp0changelogs\%mdn%
214+
215+
set out=WinPython%my_flavor%-%my_arch%bit-%WINPYVER2%_History.md
216+
%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()"
217+
copy/y %my_basedir%\bu%my_flavor%\%out% %~dp0changelogs\%out%
214218

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

216223
echo -------------------------------------- >>%my_archive_log%
217224
echo "(%date% %time%) END OF CREATION">>%my_archive_log%

make.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -119,24 +119,6 @@ def architecture_bits(self) -> int:
119119
"""Returns the architecture (32 or 64 bits) of the distribution."""
120120
return self.distribution.architecture if self.distribution else 64
121121

122-
def create_installer_7zip(self, installer_type: str = "exe", compression= "mx5"):
123-
"""Creates a WinPython installer using 7-Zip: "exe", "7z", "zip")"""
124-
self._print_action(f"Creating WinPython installer ({installer_type})")
125-
DISTDIR = self.winpython_directory
126-
filename_stem = f"Winpython{self.architecture_bits}-{self.python_full_version}.{self.build_number}{self.flavor}{self.release_level}"
127-
fullfilename = DISTDIR.parent / (filename_stem + "." + installer_type)
128-
if installer_type not in ["exe", "7z", "zip"]:
129-
return
130-
sfx_option = "-sfx7z.sfx" if installer_type == "exe" else ""
131-
zip_option = "-tzip" if installer_type == "zip" else ""
132-
compress_level = "mx5" if compression == "" else compression
133-
command = f'"{utils.find_7zip_executable()}" {zip_option} -{compress_level} a "{fullfilename}" "{DISTDIR}" {sfx_option}'
134-
print(f'Executing 7-Zip script: "{command}"')
135-
try:
136-
subprocess.run(command, shell=True, check=True, stderr=sys.stderr, stdout=sys.stderr)
137-
except subprocess.CalledProcessError as e:
138-
print(f"Error executing 7-Zip script: {e}", file=sys.stderr)
139-
140122
def _print_action(self, text: str):
141123
"""Prints an action message with progress indicator."""
142124
if self.verbose:
@@ -254,9 +236,6 @@ def make_all(build_number: int, release_level: str, basedir_wpy: Path = None,
254236

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

257-
for commmand in create_installer.lower().replace("7zip",".exe").split('.'):
258-
installer_type, compression = (commmand + "-").split("-")[:2]
259-
builder.create_installer_7zip(installer_type, compression)
260239

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

0 commit comments

Comments
 (0)