Skip to content

Commit 42d2125

Browse files
authored
Merge pull request #1691 from stonebig/master
DOS clean-up with openai: Freeze the Full Environment & Create Final …
2 parents 7d245f8 + 4148542 commit 42d2125

File tree

1 file changed

+32
-51
lines changed

1 file changed

+32
-51
lines changed

generate_a_winpython_distro.bat

Lines changed: 32 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ set "pip_lock_includedweb=%LOCKDIR%pylock.%WINPYARCH%-%WINPYVERLOCK%%my_flavor%%
126126
set "req_lock_includedlocal=%LOCKDIR%requir.%WINPYARCH%-%WINPYVERLOCK%%my_flavor%%my_release_level%_wheelslocal.txt"
127127
set "req_lock_includedweb=%LOCKDIR%requir.%WINPYARCH%-%WINPYVERLOCK%%my_flavor%%my_release_level%_wheels.txt"
128128

129-
@echo on
130129
REM === Step: Add lockfile wheels for the Wheelhouse (optional) ===
131130
if defined wheelhousereq if exist "%wheelhousereq%" (
132131
call :log_section Add wheels for the Wheelhouse
@@ -144,66 +143,48 @@ if defined wheelhousereq if exist "%wheelhousereq%" (
144143
"%my_WINPYDIRBASE%\python\scripts\wppm.exe" "%pip_lock_includedweb%" -ws "%my_find_links%" -wd "%my_WINPYDIRBASE%\wheelhouse\included.wheels"
145144
)
146145

147-
set path=%my_original_path%
148-
@echo on
149-
call %my_WINPYDIRBASE%\scripts\env.bat
150-
@echo on
151-
set WINPYVERLOCK=%WINPYVER2:.=_%
152-
set pylockinclude=%my_root_dir_for_builds%\bd%my_python_target%\bu%addlockfile%\pylock.%addlockfile%-%WINPYARCH%bit-%WINPYVERLOCK%.toml
153-
echo pylockinclude="%pylockinclude%"
154-
if not "Z%addlockfile%Z"=="ZZ" if exist "%pylockinclude%" (
155-
echo %my_WINPYDIRBASE%\python\scripts\wppm.exe "%pylockinclude%" -ws "%my_find_links%" -wd "%my_WINPYDIRBASE%\wheelhouse\included.wheels">>%my_archive_log%
156-
%my_WINPYDIRBASE%\python\scripts\wppm.exe "%pylockinclude%" -ws "%my_find_links%" -wd "%my_WINPYDIRBASE%\wheelhouse\included.wheels"
157-
)
158-
159-
@echo on
160-
161-
162-
163-
call :log_section generate pylock.toml files and requirement.txt with hash files
164-
165-
set path=%my_original_path%
166-
call %my_WINPYDIRBASE%\scripts\env.bat
167-
168-
rem generate pip freeze requirements
169-
echo %date% %time%
170-
set LOCKDIR=%WINPYDIRBASE%\..\
171-
172-
set WINPYVERLOCK=%WINPYVER2:.=_%
173-
set req=%LOCKDIR%requirement.%my_flavor%-%WINPYARCH%bit-%WINPYVERLOCK%_raw.txt
174-
set wanted_req=%LOCKDIR%requirement.%my_flavor%-%WINPYARCH%bit-%WINPYVERLOCK%.txt
146+
rem set path=%my_original_path%
147+
rem call %my_WINPYDIRBASE%\scripts\env.bat
175148

176-
set pip_lock_web=%LOCKDIR%pylock.%WINPYARCH%-%WINPYVERLOCK%%my_flavor%%my_release_level%.toml
177-
set pip_lock_local=%LOCKDIR%pylock.%WINPYARCH%-%WINPYVERLOCK%%my_flavor%%my_release_level%_local.toml
178-
set req_lock_web=%LOCKDIR%requir.%WINPYARCH%-%WINPYVERLOCK%%my_flavor%%my_release_level%.txt
179-
set req_lock_local=%LOCKDIR%requir.%WINPYARCH%-%WINPYVERLOCK%%my_flavor%%my_release_level%_local.txt
180149

150+
REM === Freeze environment and generate final lockfiles ===
151+
call :log_section Freeze environment and generate lockfiles
181152

182-
set my_archive_lockfile=%my_archive_dir%\pylock.%my_flavor%-%WINPYARCH%bit-%WINPYVERLOCK%_%date:/=-%at_%my_time%.toml
183-
set my_archive_lockfile_local=%my_archive_dir%\pylock.%my_flavor%-%WINPYARCH%bit-%WINPYVERLOCK%_%date:/=-%at_%my_time%.local.toml
184-
set my_changelog_lockfile=%~dp0changelogs\pylock.%WINPYARCH%-%WINPYVERLOCK%%my_flavor%%my_release_level%.toml
185-
set my_changelog_reqfile=%~dp0changelogs\requir.%WINPYARCH%-%WINPYVERLOCK%%my_flavor%%my_release_level%.txt
153+
set "req=%LOCKDIR%requirement.%my_flavor%-%WINPYARCH%bit-%WINPYVERLOCK%_raw.txt"
154+
set "wanted_req=%LOCKDIR%requirement.%my_flavor%-%WINPYARCH%bit-%WINPYVERLOCK%.txt"
186155

187-
python.exe -m pip freeze>%req%
188-
findstr /v "winpython" %req% > %wanted_req%
156+
set "pip_lock_web=%LOCKDIR%pylock.%WINPYARCH%-%WINPYVERLOCK%%my_flavor%%my_release_level%.toml"
157+
set "pip_lock_local=%LOCKDIR%pylock.%WINPYARCH%-%WINPYVERLOCK%%my_flavor%%my_release_level%_local.toml"
158+
set "req_lock_web=%LOCKDIR%requir.%WINPYARCH%-%WINPYVERLOCK%%my_flavor%%my_release_level%.txt"
159+
set "req_lock_local=%LOCKDIR%requir.%WINPYARCH%-%WINPYVERLOCK%%my_flavor%%my_release_level%_local.txt"
160+
161+
REM Archive paths
162+
set "my_archive_lockfile=%my_archive_dir%\pylock.%my_flavor%-%WINPYARCH%bit-%WINPYVERLOCK%_%date:/=-%at_%my_time%.toml"
163+
set "my_changelog_lockfile=%~dp0changelogs\pylock.%WINPYARCH%-%WINPYVERLOCK%%my_flavor%%my_release_level%.toml"
164+
set "my_changelog_reqfile=%~dp0changelogs\requir.%WINPYARCH%-%WINPYVERLOCK%%my_flavor%%my_release_level%.txt"
189165

166+
REM Freeze full environment (excluding winpython)
167+
python -m pip freeze > "%req%"
168+
findstr /v "winpython" "%req%" > "%wanted_req%"
190169

191-
rem pip lock from pypi, from the frozen req
192-
python.exe -m pip lock --no-deps -c C:\WinP\constraints.txt -r "%wanted_req%" -o %pip_lock_web%
170+
REM Lock from PyPI
171+
python -m pip lock --no-deps -c "%my_constraints%" -r "%wanted_req%" -o "%pip_lock_web%"
193172

194-
rem pip lock from local WheelHouse, from the frozen req
195-
python.exe -m pip lock --no-deps --no-index --trusted-host=None --find-links=C:\WinP\packages.srcreq -c C:\WinP\constraints.txt -r "%wanted_req%" -o %pip_lock_local%
173+
REM Lock from local wheelhouse
174+
python -m pip lock --no-deps --no-index --trusted-host=None --find-links="%my_find_links%" -c "%my_constraints%" -r "%wanted_req%" -o "%pip_lock_local%"
196175

197-
rem generating also classic requirement with hash-256, from obtained pylock.toml
198-
python.exe -c "from wppm import wheelhouse as wh;wh.pylock_to_req(r'%pip_lock_web%', r'%req_lock_web%')"
199-
python.exe -c "from wppm import wheelhouse as wh;wh.pylock_to_req(r'%pip_lock_local%', r'%req_lock_local%')"
176+
REM Convert both locks to requirement.txt with hash256
177+
python -c "from wppm import wheelhouse as wh; wh.pylock_to_req(r'%pip_lock_web%', r'%req_lock_web%')"
178+
python -c "from wppm import wheelhouse as wh; wh.pylock_to_req(r'%pip_lock_local%', r'%req_lock_local%')"
200179

201-
rem compare the two (result from pypi and local Wheelhouse must be equal)
202-
fc "%req_lock_web%" "%req_lock_local%"
180+
REM Compare for reproducibility check
181+
fc "%req_lock_web%" "%req_lock_local%"
182+
@echo off
203183

204-
copy/Y %pip_lock_web% %my_archive_lockfile%
205-
copy/Y %pip_lock_web% %my_changelog_lockfile%
206-
copy/Y %req_lock_web% %my_changelog_reqfile%
184+
REM Archive generated lockfile
185+
copy /Y "%pip_lock_web%" "%my_archive_lockfile%"
186+
copy /Y "%pip_lock_web%" "%my_changelog_lockfile%"
187+
copy /Y "%req_lock_web%" "%my_changelog_reqfile%"
207188

208189

209190
call :log_section Archive success

0 commit comments

Comments
 (0)