diff --git a/.github/workflows/update-dependencies.yml b/.github/workflows/update-dependencies.yml index 1a4e1b69..22dbf46e 100644 --- a/.github/workflows/update-dependencies.yml +++ b/.github/workflows/update-dependencies.yml @@ -35,6 +35,8 @@ jobs: run: nox --force-color --error-on-missing-interpreters -s update_native_dependencies env: GITHUB_API_TOKEN: ${{ steps.generate-token.outputs.token || github.token }} + - name: "Run update downloaded interpreters" + run: nox --force-color --error-on-missing-interpreters -s update_interpreters_download - name: "Run update python dependencies" run: nox --force-color --error-on-missing-interpreters -s update_python_dependencies update_python_tools - name: Create Pull Request diff --git a/tools/update_interpreters_download.py b/tools/update_interpreters_download.py index b50b1da8..094653e4 100644 --- a/tools/update_interpreters_download.py +++ b/tools/update_interpreters_download.py @@ -1,6 +1,8 @@ from __future__ import annotations +import argparse import json +import subprocess from hashlib import sha256 from pathlib import Path @@ -13,7 +15,7 @@ PYTHON_VERSIONS = PROJECT_ROOT / "docker" / "build_scripts" / "python_versions.json" -def update_pypy_version(releases, py_spec, pp_spec, tag, arch, version_dict): +def update_pypy_version(releases, py_spec, pp_spec, tag, arch, version_dict, updates): pypy_arch = {"x86_64": "x64"}.get(arch, arch) current_version = None if "version" in version_dict: @@ -32,7 +34,8 @@ def update_pypy_version(releases, py_spec, pp_spec, tag, arch, version_dict): ) except StopIteration: continue - print(f"updating {tag} {arch} to {r['pypy_version']}") + message = f"updating {tag} {arch} to {r['pypy_version']}" + print(message) response = requests.get(file["download_url"], stream=True) response.raise_for_status() sha256sum = sha256() @@ -41,10 +44,11 @@ def update_pypy_version(releases, py_spec, pp_spec, tag, arch, version_dict): version_dict["version"] = str(r["pypy_version"]) version_dict["download_url"] = file["download_url"] version_dict["sha256"] = sha256sum.hexdigest() + updates.append(message) break -def update_pypy_versions(versions): +def update_pypy_versions(versions, updates): response = requests.get("https://downloads.python.org/pypy/versions.json") response.raise_for_status() releases = [r for r in response.json() if r["pypy_version"] != "nightly"] @@ -74,14 +78,24 @@ def update_pypy_versions(versions): pp_spec = Specifier(f"=={pp_major}.{pp_minor}.*") for arch in versions[tag]: update_pypy_version( - releases, py_spec, pp_spec, tag, arch, versions[tag][arch] + releases, py_spec, pp_spec, tag, arch, versions[tag][arch], updates ) def main(): + parser = argparse.ArgumentParser() + parser.add_argument("--dry-run", dest="dry_run", action="store_true", help="dry run") + args = parser.parse_args() versions = json.loads(PYTHON_VERSIONS.read_text()) - update_pypy_versions(versions) - PYTHON_VERSIONS.write_text(json.dumps(versions, indent=2)) + updates = [] + update_pypy_versions(versions, updates) + if not args.dry_run: + PYTHON_VERSIONS.write_text(json.dumps(versions, indent=2)) + if updates: + details = "\n".join(f"- {message}" for message in updates) + subprocess.check_call( + ["git", "commit", "-am", "Update downloaded interpreters", "-m", details] + ) if __name__ == "__main__":