Skip to content

Commit f7616de

Browse files
committed
DOS clean-up with openai: Centralize and simplify log writing
1 parent f16a1ea commit f7616de

File tree

1 file changed

+26
-35
lines changed

1 file changed

+26
-35
lines changed

generate_a_winpython_distro.bat

Lines changed: 26 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,7 @@ set "my_WINPYDIRBASE=%my_basedir%\bu%my_flavor%\WPy%my_arch%-%my_python_target_r
4242
rem a building env need is a Python with packages: WinPython + build + flit + packaging + mkshim400.py
4343
set my_buildenv=C:\WinPdev\WPy64-310111
4444

45-
46-
47-
48-
echo -------------------------------------- >>%my_archive_log%
49-
echo (%date% %time%) preparing winPython for %my_pyver% (%my_python_target%)release %my_release%%my_flavor% (%my_release_level%) *** %my_arch% bit ***>>%my_archive_log%
50-
echo -------------------------------------- >>%my_archive_log%
45+
call :log_section preparing winPython for %my_pyver% (%my_python_target%)release %my_release%%my_flavor% (%my_release_level%) *** %my_arch% bit ***
5146

5247
rem Pre-clear previous build infrastructure
5348
if "%my_preclear_build_directory%"=="Yes" (
@@ -63,20 +58,18 @@ if "%my_preclear_build_directory%"=="Yes" (
6358
rmdir /S /Q dist
6459
)
6560

66-
REM Create a new build
67-
echo -------------------------------------- >>%my_archive_log%
68-
echo "(%date% %time%) Create a new build">>%my_archive_log%
69-
echo -------------------------------------- >>%my_archive_log%
61+
call :log_section Create a new build
62+
7063
cd /D %~dp0
7164
set path=%my_original_path%
7265
call %my_buildenv%\scripts\env.bat
7366
@echo on
7467

75-
REM Create basic build infrastructure
68+
call :log_section Create basic build infrastructure
7669
echo "(%date% %time%) Create basic build infrastructure">>%my_archive_log%
7770
python.exe -c "from make import *;make_all(%my_release%, '%my_release_level%', basedir_wpy=r'%my_WINPYDIRBASE%', verbose=True, flavor='%my_flavor%', source_dirs=r'%my_source_dirs%', toolsdirs=r'%my_toolsdirs%')">>%my_archive_log%
7871

79-
REM Check infrastructure is in place
72+
call :log_section Check infrastructure is in place
8073
echo "(%date% %time%) Check infrastructure">>%my_archive_log%
8174
set WINPYDIRBASE=%my_WINPYDIRBASE%
8275

@@ -92,10 +85,7 @@ if not exist %my_WINPYDIRBASE%\scripts\env.bat (
9285
exit
9386
)
9487

95-
REM Add pre-requisite packages
96-
echo -------------------------------------- >>%my_archive_log%
97-
echo "(%date% %time%) Add pre-requisite packages">>%my_archive_log%
98-
echo -------------------------------------- >>%my_archive_log%
88+
call :log_section Add pre-requisite packages
9989

10090
set path=%my_original_path%
10191
call %my_WINPYDIRBASE%\scripts\env.bat
@@ -112,17 +102,13 @@ if not "Z%my_requirements_pre%Z"=="ZZ" (
112102
echo "No pre-requisite packages">>%my_archive_log%
113103
)
114104

115-
REM Add requirement packages
116-
echo -------------------------------------- >>%my_archive_log%
117-
echo "(%date% %time%) Add requirement packages">>%my_archive_log%
118-
echo -------------------------------------- >>%my_archive_log%
105+
call :log_section Add requirement packages
106+
119107
python -m pip install -r %my_requirements% -c %my_constraints% --pre --no-index --trusted-host=None --find-links=%my_find_links% >>%my_archive_log%
120108
python -c "from wppm import wppm;dist=wppm.Distribution(r'%WINPYDIR%');dist.patch_standard_packages('', to_movable=True)"
121109

122-
REM Add Wheelhouse (to replace per pip lock direct ? would allow paralellism)
123-
echo -------------------------------------- >>%my_archive_log%
124-
echo "(%date% %time%) Add lockfile wheels">>%my_archive_log%
125-
echo -------------------------------------- >>%my_archive_log%
110+
call :log_section Add lockfile wheels
111+
126112
set path=%my_original_path%
127113
@echo on
128114
call %my_WINPYDIRBASE%\scripts\env.bat
@@ -164,9 +150,7 @@ echo %my_WINPYDIRBASE%\python\scripts\wppm.exe "%pip_lock_includedweb%" -ws "%m
164150
%my_WINPYDIRBASE%\python\scripts\wppm.exe "%pip_lock_includedweb%" -ws "%my_find_links%" -wd "%my_WINPYDIRBASE%\wheelhouse\included.wheels"
165151
)
166152

167-
echo -------------------------------------- >>%my_archive_log%;
168-
echo "(%date% %time%) generate pylock.toml files and requirement.txt with hash files">>%my_archive_log%
169-
echo -------------------------------------- >>%my_archive_log%
153+
call :log_section generate pylock.toml files and requirement.txt with hash files
170154

171155
set path=%my_original_path%
172156
call %my_WINPYDIRBASE%\scripts\env.bat
@@ -212,10 +196,8 @@ copy/Y %pip_lock_web% %my_changelog_lockfile%
212196
copy/Y %req_lock_web% %my_changelog_reqfile%
213197

214198

215-
REM Archive success
216-
echo -------------------------------------- >>%my_archive_log%
217-
echo "(%date% %time%) Archive success">>%my_archive_log%
218-
echo -------------------------------------- >>%my_archive_log%
199+
call :log_section Archive success
200+
219201
set path=%my_original_path%
220202
call %my_WINPYDIRBASE%\scripts\env.bat
221203

@@ -237,10 +219,19 @@ rem compress
237219
set stem=WinPython%my_arch%-%WINPYVER2%%my_flavor%%my_release_level%
238220
%target_python_exe% -c "from wppm import utils;utils.command_installer_7zip(r'%my_WINPYDIRBASE%', r'%my_WINPYDIRBASE%\..',r'%stem%', r'%my_create_installer%')"
239221

240-
echo -------------------------------------- >>%my_archive_log%
241-
echo "(%date% %time%) END OF CREATION">>%my_archive_log%
242-
echo -------------------------------------- >>%my_archive_log%
222+
call :log_section END OF CREATION
223+
243224
start notepad.exe %my_archive_log%
244225
start notepad.exe %my_archive_log%.packages_versions.txt
245226

246-
set path=%my_original_path%
227+
set path=%my_original_path%
228+
pause
229+
exit
230+
231+
:log_section
232+
echo. >>%my_archive_log%
233+
echo -------------------------------------- >>%my_archive_log%
234+
echo (%date% %time%) %* >>%my_archive_log%
235+
echo -------------------------------------- >>%my_archive_log%
236+
echo. >>%my_archive_log%
237+
exit /b

0 commit comments

Comments
 (0)