Skip to content

[pull] master from winpython:master #56

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 18 additions & 9 deletions generate_a_winpython_distro.bat
Original file line number Diff line number Diff line change
Expand Up @@ -115,38 +115,47 @@ 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%
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

rem to get pylock.toml in a ok place...
cd/D %LOCKDIR%

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%

rem pip lock from pypi, from the 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%

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%"
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 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 "%pip_lock_web%" "%pip_lock_local%"

copy/Y %pip_lock_web% %my_archive_lockfile%
copy/Y %pip_lock_web% %my_changelog_lockfile%
Expand Down
2 changes: 1 addition & 1 deletion winpython/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@
OTHER DEALINGS IN THE SOFTWARE.
"""

__version__ = '15.5.20250511'
__version__ = '15.5620250513'
__license__ = __doc__
__project_url__ = 'http://winpython.github.io/'
12 changes: 10 additions & 2 deletions pylock_to_requirements.py → winpython/wheelhouse.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#
# WheelHouse.py
import sys
from pathlib import Path
from collections import defaultdict
Expand All @@ -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])
Expand Down Expand Up @@ -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"]
Expand All @@ -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")
Expand Down