This is an automated email from the ASF dual-hosted git repository.

bugraoz pushed a commit to branch v3-1-test
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/v3-1-test by this push:
     new 7c2ad006410 [v3-1-test] Read Python version from static www/ftp 
information (#61904) (#61905)
7c2ad006410 is described below

commit 7c2ad006410c95ccf4d5be1f486b81f9971f5a43
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Sat Feb 14 12:45:15 2026 +0100

    [v3-1-test] Read Python version from static www/ftp information (#61904) 
(#61905)
    
    Release version check for Python started to fail with rate limit,
    this PR changes Python version retrieval to use static information
    hosted on ftp site of Python (which is behind CDN and can handle
    much bigger traffic and is read-only so there are no rate limits
    involved.
    (cherry picked from commit 35505370cb6071b302ae1c3eeae34714f823a9cc)
    
    Co-authored-by: Jarek Potiuk <[email protected]>
---
 scripts/ci/prek/upgrade_important_versions.py | 37 +++++++++++++++++++--------
 1 file changed, 26 insertions(+), 11 deletions(-)

diff --git a/scripts/ci/prek/upgrade_important_versions.py 
b/scripts/ci/prek/upgrade_important_versions.py
index 9b8e9e63204..f7db853356d 100755
--- a/scripts/ci/prek/upgrade_important_versions.py
+++ b/scripts/ci/prek/upgrade_important_versions.py
@@ -116,27 +116,42 @@ def get_latest_pypi_version(package_name: str, 
should_upgrade: bool) -> str:
 
 
 def get_all_python_versions() -> list[Version]:
+    """
+    Fetch all released Python versions by parsing the Python FTP directory 
listing.
+    This provides static information about all available Python releases.
+    """
     if VERBOSE:
-        console.print("[bright_blue]Fetching all released Python versions from 
python.org")
-    url = "https://www.python.org/api/v2/downloads/release/?is_published=true";
+        console.print("[bright_blue]Fetching all released Python versions from 
python.org FTP")
+    url = "https://www.python.org/ftp/python/";
     headers = {"User-Agent": "Python requests"}
     response = requests.get(url, headers=headers)
     response.raise_for_status()
-    data = response.json()
+
+    # Parse the HTML directory listing to extract version numbers
+    # The FTP directory listing has links like: <a href="3.12.1/">3.12.1/</a>
     versions = []
-    matcher = re.compile(r"^Python ([\d.]+$)")
-    for release in data:
-        release_name = release["name"]
-        match = matcher.match(release_name)
-        if match:
-            versions.append(Version(match.group(1)))
+    # Match version patterns like "3.12.1/" in href attributes
+    version_pattern = re.compile(r'href="(\d+\.\d+\.\d+)/"')
+
+    for match in version_pattern.finditer(response.text):
+        version_str = match.group(1)
+        try:
+            # Parse as version to validate it's a proper version number
+            version_obj = Version(version_str)
+            # Only include Python 3.x versions
+            if version_obj.major == 3:
+                versions.append(version_obj)
+        except Exception:
+            # Skip invalid version strings
+            continue
+
     return versions
 
 
 def get_latest_python_version(python_major_minor: str, all_versions: 
list[Version]) -> str:
     """
-    Fetch the latest released Python version for a given major.minor (e.g. 
'3.12') using python.org API.
-    Much faster than paginating through all GitHub tags.
+    Fetch the latest released Python version for a given major.minor (e.g. 
'3.12') from FTP directory listing.
+    Uses static directory information rather than API calls.
     """
     # Only consider releases matching the major.minor.patch pattern
     matching = [

Reply via email to