diff --git a/generate_a_winpython_distro.bat b/generate_a_winpython_distro.bat index cdabf95e..1766a18d 100644 --- a/generate_a_winpython_distro.bat +++ b/generate_a_winpython_distro.bat @@ -115,7 +115,7 @@ call %my_buildenv%\scripts\env.bat 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% echo -------------------------------------- >>%my_archive_log% -echo "(%date% %time%) generate lock files">>%my_archive_log% +echo "(%date% %time%) generate pylock.tomle files and requirement_with_hash.txt files">>%my_archive_log% echo -------------------------------------- >>%my_archive_log% set path=%my_original_path% @@ -123,30 +123,34 @@ call %my_WINPYDIRBASE%\scripts\env.bat rem generate pip freeze requirements echo %date% %time% -set LOCKDIR=%WINPYDIRBASE%\notebooks\ +set LOCKDIR=%WINPYDIRBASE%\..\ set req=%LOCKDIR%requirement_%WINPYVER%_raw.txt set wanted_req=%LOCKDIR%requirement_%WINPYVER%.txt set pip_lock_web=%LOCKDIR%pylock_%WINPYVER%.toml set pip_lock_local=%LOCKDIR%pylock_%WINPYVER%_local.toml +set req_lock_web=%LOCKDIR%requirement_with_hash_%WINPYVER%.txt +set req_lock_local=%LOCKDIR%requirement_with_hash_%WINPYVER%_local.txt + set my_archive_lockfile=%my_archive_dir%\pylock_%WINPYVER%_%date:/=-%at_%my_time%.toml set my_archive_lockfile_local=%my_archive_dir%\pylock_%WINPYVER%_%date:/=-%at_%my_time%_local.tml set my_changelog_lockfile=%~dp0changelogs\pylock_%WINPYVER%.toml - python.exe -m pip freeze>%req% findstr /v "winpython" %req% > %wanted_req% -rem pip lock from pypi the local, from a frozen req -python.exe -m pip lock --no-deps -c C:\WinP\constraints.txt -r %wanted_req% -copy pylock.toml %pip_lock_web% -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% -copy pylock.toml %pip_lock_local% -rem compare the two -findstr /V /R "^url =$" %pip_lock_web% > %pip_lock_web%.no_url.txt -findstr /V /R "^url =$" %pip_lock_local% > %pip_lock_local%.no_url.txt +rem pip lock from pypi, from the frozen req +python.exe -m pip lock --no-deps -c C:\WinP\constraints.txt -r "%wanted_req%" -o %pip_lock_web% + +rem pip lock from local WheelHouse, from the frozen req +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% + +rem generating also classic requirement with hash-256, from obtained pylock.toml +python.exe -c "from winpython import wheelhouse as wh;wh.pylock_to_req(r'%pip_lock_web%', r'%req_lock_web%')" +python.exe -c "from winpython import wheelhouse as wh;wh.pylock_to_req(r'%pip_lock_local%', r'%req_lock_local%')" -fc %pip_lock_web%.no_url.txt %pip_lock_local%.no_url.txt +rem compare the two (result from pypi and local Wheelhouse must be equal) +fc "%req_lock_web%" "%req_lock_local%" copy/Y %pip_lock_web% %my_archive_lockfile% copy/Y %pip_lock_web% %my_changelog_lockfile% diff --git a/winpython/__init__.py b/winpython/__init__.py index c1fdd2f8..cac91627 100644 --- a/winpython/__init__.py +++ b/winpython/__init__.py @@ -28,6 +28,6 @@ OTHER DEALINGS IN THE SOFTWARE. """ -__version__ = '15.5.20250511' +__version__ = '15.5620250513' __license__ = __doc__ __project_url__ = 'http://winpython.github.io/' diff --git a/pylock_to_requirements.py b/winpython/wheelhouse.py similarity index 86% rename from pylock_to_requirements.py rename to winpython/wheelhouse.py index 9438233f..b29f560e 100644 --- a/pylock_to_requirements.py +++ b/winpython/wheelhouse.py @@ -1,3 +1,5 @@ +# +# WheelHouse.py import sys from pathlib import Path from collections import defaultdict @@ -15,7 +17,7 @@ def parse_pylock_toml(path): - with open(path, "rb") as f: + with open(Path(path), "rb") as f: data = tomllib.load(f) # This dictionary maps package names to (version, [hashes]) @@ -46,7 +48,7 @@ def parse_pylock_toml(path): def write_requirements_txt(package_hashes, output_path="requirements.txt"): - with open(output_path, "w") as f: + with open(Path(output_path), "w") as f: for name, data in sorted(package_hashes.items()): version = data["version"] hashes = data["hashes"] @@ -61,6 +63,12 @@ def write_requirements_txt(package_hashes, output_path="requirements.txt"): print(f"✅ requirements.txt written to {output_path}") +def pylock_to_req(path, output_path=None): + pkgs = parse_pylock_toml(path) + if not output_path: + output_path = path.parent / (path.stem.replace('pylock','requirement_with_hash')+ '.txt') + write_requirements_txt(pkgs, output_path) + if __name__ == "__main__": if len(sys.argv) != 2: print("Usage: python pylock_to_requirements.py pylock.toml")