Skip to content

[pull] master from winpython:master #55

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 7 commits into from
May 11, 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
43 changes: 40 additions & 3 deletions generate_a_winpython_distro.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ rem generate_a_winpython_distro.bat: to be launched from a winpython directory,
@echo on

REM Initialize variables
if "%my_release_level%"=="" set my_release_level=b3
if "%my_release_level%"=="" set my_release_level=b1
if "%my_create_installer%"=="" set my_create_installer=True

rem Set archive directory and log file
Expand All @@ -26,8 +26,8 @@ if "%target_python_exe%"=="" set target_python_exe=python.exe

rem Set Python target release based on my_python_target
if %my_python_target%==311 set my_python_target_release=3119& set my_release=1
if %my_python_target%==312 set my_python_target_release=31210& set my_release=0
if %my_python_target%==313 set my_python_target_release=3133& set my_release=0
if %my_python_target%==312 set my_python_target_release=31210& set my_release=1
if %my_python_target%==313 set my_python_target_release=3133& set my_release=1
if %my_python_target%==314 set my_python_target_release=3140& set my_release=0

echo -------------------------------------- >>%my_archive_log%
Expand Down Expand Up @@ -114,6 +114,43 @@ cd /D %~dp0
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 -------------------------------------- >>%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 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 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

fc %pip_lock_web%.no_url.txt %pip_lock_local%.no_url.txt

copy/Y %pip_lock_web% %my_archive_lockfile%
copy/Y %pip_lock_web% %my_changelog_lockfile%

echo -------------------------------------- >>%my_archive_log%
echo "(%date% %time%) END OF CREATION">>%my_archive_log%
echo -------------------------------------- >>%my_archive_log%
Expand Down
Binary file modified portable/launchers_final/IDLE (Python GUI).exe
Binary file not shown.
76 changes: 76 additions & 0 deletions pylock_to_requirements.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import sys
from pathlib import Path
from collections import defaultdict

# Use tomllib if available (Python 3.11+), otherwise fall back to tomli
try:
import tomllib # Python 3.11+
except ImportError:
try:
import tomli as tomllib # For older Python versions
except ImportError:
print("Please install tomli for Python < 3.11: pip install tomli")
sys.exit(1)



def parse_pylock_toml(path):
with open(path, "rb") as f:
data = tomllib.load(f)

# This dictionary maps package names to (version, [hashes])
package_hashes = defaultdict(lambda: {"version": "", "hashes": []})

for entry in data.get("packages", []):
name = entry["name"]
version = entry["version"]
all_hashes = []

# Handle wheels
for wheel in entry.get("wheels", []):
sha256 = wheel.get("hashes", {}).get("sha256")
if sha256:
all_hashes.append(sha256)

# Handle sdist (if present)
sdist = entry.get("sdist")
if sdist and "hashes" in sdist:
sha256 = sdist["hashes"].get("sha256")
if sha256:
all_hashes.append(sha256)

package_hashes[name]["version"] = version
package_hashes[name]["hashes"].extend(all_hashes)

return package_hashes


def write_requirements_txt(package_hashes, output_path="requirements.txt"):
with open(output_path, "w") as f:
for name, data in sorted(package_hashes.items()):
version = data["version"]
hashes = data["hashes"]

if hashes:
f.write(f"{name}=={version} \\\n")
for i, h in enumerate(hashes):
end = " \\\n" if i < len(hashes) - 1 else "\n"
f.write(f" --hash=sha256:{h}{end}")
else:
f.write(f"{name}=={version}\n")

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

if __name__ == "__main__":
if len(sys.argv) != 2:
print("Usage: python pylock_to_requirements.py pylock.toml")
sys.exit(1)

path = Path(sys.argv[1])
if not path.exists():
print(f"❌ File not found: {path}")
sys.exit(1)

pkgs = parse_pylock_toml(path)
dest = path.parent / (path.stem.replace('pylock','requirement_with_hash')+ '.txt')
write_requirements_txt(pkgs, dest)
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.4.20250507'
__version__ = '15.5.20250511'
__license__ = __doc__
__project_url__ = 'http://winpython.github.io/'