8000 generate pylock.toml and requirement_with_hash.txt at end of build · winpython/winpython@d87e945 · GitHub
[go: up one dir, main page]

Skip to content

Commit d87e945

Browse files
committed
generate pylock.toml and requirement_with_hash.txt at end of build
creating a Wheelhouse.py separated file, that should grow the full WheelHouse feature
1 parent 92022e4 commit d87e945

File tree

3 files changed

+29
-12
lines changed

3 files changed

+29
-12
lines changed

generate_a_winpython_distro.bat

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -115,38 +115,47 @@ call %my_buildenv%\scripts\env.bat
115115
python.exe -c "from make import *;make_all(%my_release%, '%my_release_level%', pyver='%my_pyver%', basedir=r'%my_basedir%', verbose=True, architecture=%my_arch%, 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%
116116

117117
echo -------------------------------------- >>%my_archive_log%
118-
echo "(%date% %time%) generate lock files">>%my_archive_log%
118+
echo "(%date% %time%) generate pylock.tomle files and requirement_with_hash.txt files">>%my_archive_log%
119119
echo -------------------------------------- >>%my_archive_log%
120120

121121
set path=%my_original_path%
122122
call %my_WINPYDIRBASE%\scripts\env.bat
123123

124124
rem generate pip freeze requirements
125125
echo %date% %time%
126-
set LOCKDIR=%WINPYDIRBASE%\notebooks\
126+
set LOCKDIR=%WINPYDIRBASE%\..\
127127
set req=%LOCKDIR%requirement_%WINPYVER%_raw.txt
128128
set wanted_req=%LOCKDIR%requirement_%WINPYVER%.txt
129129
set pip_lock_web=%LOCKDIR%pylock_%WINPYVER%.toml
130130
set pip_lock_local=%LOCKDIR%pylock_%WINPYVER%_local.toml
131+
set req_lock_web=%LOCKDIR%requirement_with_hash_%WINPYVER%.txt
132+
set req_lock_local=%LOCKDIR%requirement_with_hash_%WINPYVER%_local.txt
133+
131134
set my_archive_lockfile=%my_archive_dir%\pylock_%WINPYVER%_%date:/=-%at_%my_time%.toml
132135
set my_archive_lockfile_local=%my_archive_dir%\pylock_%WINPYVER%_%date:/=-%at_%my_time%_local.tml
133136
set my_changelog_lockfile=%~dp0changelogs\pylock_%WINPYVER%.toml
134137

138+
rem to get pylock.toml in a ok place...
139+
cd/D %LOCKDIR%
135140

136141
python.exe -m pip freeze>%req%
137142
findstr /v "winpython" %req% > %wanted_req%
138143

139-
rem pip lock from pypi the local, from a frozen req
140-
python.exe -m pip lock --no-deps -c C:\WinP\constraints.txt -r %wanted_req%
144+
145+
rem pip lock from pypi, from the frozen req
146+
python.exe -m pip lock --no-deps -c C:\WinP\constraints.txt -r "%wanted_req%"
141147
copy pylock.toml %pip_lock_web%
142-
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%
148+
149+
rem pip lock from local WheelHouse, from the frozen req
150+
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%"
143151
copy pylock.toml %pip_lock_local%
144152

145-
rem compare the two
146-
findstr /V /R "^url =$" %pip_lock_web% > %pip_lock_web%.no_url.txt
147-
findstr /V /R "^url =$" %pip_lock_local% > %pip_lock_local%.no_url.txt
153+
rem generating also classic requirement with hash-256, from obtained pylock.toml
154+
python.exe -c "from winpython import wheelhouse as wh;wh.pylock_to_req(r'%pip_lock_web%', r'%req_lock_web%')"
155+
python.exe -c "from winpython import wheelhouse as wh;wh.pylock_to_req(r'%pip_lock_local%', r'%req_lock_local%')"
148156

149-
fc %pip_lock_web%.no_url.txt %pip_lock_local%.no_url.txt
157+
rem compare the two (result from pypi and local Wheelhouse must be equal)
158+
fc "%pip_lock_web%" "%pip_lock_local%"
150159

151160
copy/Y %pip_lock_web% %my_archive_lockfile%
152161
copy/Y %pip_lock_web% %my_changelog_lockfile%

winpython/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@
2828
OTHER DEALINGS IN THE SOFTWARE.
2929
"""
3030

31-
__version__ = '15.5.20250511'
31+
__version__ = '15.5620250513'
3232
__license__ = __doc__
3333
__project_url__ = 'http://winpython.github.io/'

pylock_to_requirements.py renamed to winpython/wheelhouse.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#
2+
# WheelHouse.py
13
import sys
24
from pathlib import Path
35
from collections import defaultdict
@@ -15,7 +17,7 @@
1517

1618

1719
def parse_pylock_toml(path):
18-
with open(path, "rb") as f:
20+
with open(Path(path), "rb") as f:
1921
data = tomllib.load(f)
2022

2123
# This dictionary maps package names to (version, [hashes])
@@ -46,7 +48,7 @@ def parse_pylock_toml(path):
4648

4749

4850
def write_requirements_txt(package_hashes, output_path="requirements.txt"):
49-
with open(output_path, "w") as f:
51+
with open(Path(output_path), "w") as f:
5052
for name, data in sorted(package_hashes.items()):
5153
version = data["version"]
5254
hashes = data["hashes"]
@@ -61,6 +63,12 @@ def write_requirements_txt(package_hashes, output_path="requirements.txt"):
6163

6264
print(f"✅ requirements.txt written to {output_path}")
6365

66+
def pylock_to_req(path, output_path=None):
67+
pkgs = parse_pylock_toml(path)
68+
if not output_path:
69+
output_path = path.parent / (path.stem.replace('pylock','requirement_with_hash')+ '.txt')
70+
write_requirements_txt(pkgs, output_path)
71+
6472
if __name__ == "__main__":
6573
if len(sys.argv) != 2:
6674
print("Usage: python pylock_to_requirements.py pylock.toml")

0 commit comments

Comments
 (0)
0