From 51dc3c1eb721e03b6371029bbcbfff18ab72c6a9 Mon Sep 17 00:00:00 2001 From: Ross McFarland Date: Mon, 17 Nov 2025 09:03:21 -0800 Subject: [PATCH] Script to update .ci-config.json with current python versions --- .../7964691076224439b4c8b9bcef2e4bb6.md | 4 ++ .ci-config.json | 8 ++- script/update-python-versions | 58 +++++++++++++++++++ 3 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 .changelog/7964691076224439b4c8b9bcef2e4bb6.md create mode 100755 script/update-python-versions diff --git a/.changelog/7964691076224439b4c8b9bcef2e4bb6.md b/.changelog/7964691076224439b4c8b9bcef2e4bb6.md new file mode 100644 index 0000000..c62e73d --- /dev/null +++ b/.changelog/7964691076224439b4c8b9bcef2e4bb6.md @@ -0,0 +1,4 @@ +--- +type: none +--- +Script to update .ci-config.json with current python versions \ No newline at end of file diff --git a/.ci-config.json b/.ci-config.json index 65ec95d..22edf29 100644 --- a/.ci-config.json +++ b/.ci-config.json @@ -1,4 +1,10 @@ { "python_version_current": "3.14", - "python_versions_active": ["3.10", "3.11", "3.12", "3.13", "3.14"] + "python_versions_active": [ + "3.10", + "3.11", + "3.12", + "3.13", + "3.14" + ] } diff --git a/script/update-python-versions b/script/update-python-versions new file mode 100755 index 0000000..9f53891 --- /dev/null +++ b/script/update-python-versions @@ -0,0 +1,58 @@ +#!/usr/bin/env python3 + +from datetime import date, datetime +from json import dump, load +from urllib.request import urlopen + +# Fetch Python version data from endoflife.date +with urlopen('https://endoflife.date/api/python.json') as response: + versions = load(response) + +# Get today's date for EOL comparison +today = date.today() + +# Filter for active versions (released and not EOL'd yet) +active_versions = [] +for version in versions: + cycle = version['cycle'] + + # Skip Python 2.x versions + if cycle.startswith('2.'): + continue + + # Check if version has been released + release_date_str = version.get('releaseDate') + if release_date_str: + release_date = datetime.strptime(release_date_str, '%Y-%m-%d').date() + if release_date > today: + # Skip pre-release versions + continue + + # Check if version is not EOL'd yet + eol_str = version.get('eol') + if eol_str: + eol_date = datetime.strptime(eol_str, '%Y-%m-%d').date() + if eol_date >= today: + active_versions.append(cycle) + +# Sort versions +active_versions.sort(key=lambda v: tuple(map(int, v.split('.')))) + +# Determine current version (the latest active version) +current_version = active_versions[-1] if active_versions else None + +# Update .ci-config.json +config_path = '.ci-config.json' +with open(config_path, 'r') as fh: + config = load(fh) + +config['python_versions_active'] = active_versions +config['python_version_current'] = current_version + +with open(config_path, 'w') as fh: + dump(config, fh, indent=2) + fh.write('\n') + +print(f'Updated {config_path}:') +print(f' Active versions: {", ".join(active_versions)}') +print(f' Current version: {current_version}')