Produce releases for Python 3.13. (#18799)

Progress on https://github.com/iree-org/iree/issues/18652. This builds
release packages for:

| | 3.13 | 3.13t |
| -- | -- | -- |
| Linux | Yes | Yes |
| macOS | Yes | No |
| Windows | Yes | No |

Actually using the free-threading features in Python 3.13t may need
changes like https://github.com/iree-org/iree/pull/18770.

Tested at https://github.com/iree-org/iree/actions/runs/11371528748
(Windows build will be fixed with a more recent commit and a few
patches). Assets were uploaded to
https://github.com/iree-org/iree/releases/tag/candidate-20241016.21.
diff --git a/.github/workflows/build_package.yml b/.github/workflows/build_package.yml
index 353dd73..81a720c 100644
--- a/.github/workflows/build_package.yml
+++ b/.github/workflows/build_package.yml
@@ -98,7 +98,7 @@
 
     env:
       # These are also set in: build_tools/python_deploy/build_linux_packages.sh
-      MANYLINUX_X86_64_IMAGE: ghcr.io/iree-org/manylinux_x86_64@sha256:facedb71df670016e74e646d71e869e6fff70d4cdbaa6634d4d0a10d6e174399
+      MANYLINUX_X86_64_IMAGE: ghcr.io/iree-org/manylinux_x86_64@sha256:2e0246137819cf10ed84240a971f9dd75cc3eb62dc6907dfd2080ee966b3c9f4
       MANYLINUX_AARCH64_IMAGE: quay.io/pypa/manylinux_2_28_aarch64
 
     steps:
@@ -119,6 +119,9 @@
       - name: "Configure MSVC (Windows)"
         if: "matrix.build-family == 'windows'"
         uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0
+      - name: Install dependencies (macOS)
+        if: "matrix.build-family == 'macos'"
+        run: sudo ./c/build_tools/python_deploy/install_macos_deps.sh
 
       ##########################################################################
       # Write version_info.json
@@ -206,7 +209,7 @@
           package_suffix: ${{ github.event.inputs.package_suffix }}
           packages: "iree-runtime"
           output_dir: "${{ github.workspace }}/bindist"
-          override_python_versions: "3.11 3.12"
+          override_python_versions: "3.11 3.12 3.13"
         run: |
           [ -e ./bindist/* ] && rm ./bindist/*
           ./c/build_tools/python_deploy/build_macos_packages.sh
@@ -218,7 +221,7 @@
           package_suffix: ${{ github.event.inputs.package_suffix }}
           packages: "iree-runtime"
           output_dir: "${{ github.workspace }}/bindist"
-          override_python_versions: "3.11 3.12"
+          override_python_versions: "3.11 3.12 3.13"
         run: |
           if (Test-Path -Path "${{ github.workspace }}/bindist") {
             Remove-Item -Path "${{ github.workspace }}/bindist" -Recurse -Force
@@ -248,7 +251,7 @@
           package_suffix: ${{ github.event.inputs.package_suffix }}
           packages: "iree-compiler"
           output_dir: "${{ github.workspace }}/bindist"
-          override_python_versions: "3.11 3.12"
+          override_python_versions: "3.11 3.12 3.13"
         run: |
           [ -e ./bindist/* ] && rm ./bindist/*
           ./c/build_tools/python_deploy/build_macos_packages.sh
@@ -260,7 +263,7 @@
           package_suffix: ${{ github.event.inputs.package_suffix }}
           packages: "iree-compiler"
           output_dir: "${{ github.workspace }}/bindist"
-          override_python_versions: "3.11 3.12"
+          override_python_versions: "3.11 3.12 3.13"
         run: |
           if (Test-Path -Path "${{ github.workspace }}/bindist") {
             Remove-Item -Path "${{ github.workspace }}/bindist" -Recurse -Force
diff --git a/.github/workflows/pkgci_build_packages.yml b/.github/workflows/pkgci_build_packages.yml
index 16ed708..9df12ed 100644
--- a/.github/workflows/pkgci_build_packages.yml
+++ b/.github/workflows/pkgci_build_packages.yml
@@ -20,7 +20,7 @@
       fail-fast: false
     env:
       CACHE_DIR: ${{ github.workspace }}/.iree-container-cache
-      MANYLINUX_DOCKER_IMAGE: ghcr.io/iree-org/manylinux_x86_64@sha256:facedb71df670016e74e646d71e869e6fff70d4cdbaa6634d4d0a10d6e174399
+      MANYLINUX_DOCKER_IMAGE: ghcr.io/iree-org/manylinux_x86_64@sha256:2e0246137819cf10ed84240a971f9dd75cc3eb62dc6907dfd2080ee966b3c9f4
       PACKAGE_SUFFIX: ""
     steps:
       - name: Prefetch Docker
@@ -85,7 +85,7 @@
 #     fail-fast: false
 #   env:
 #     CACHE_DIR: ${{ github.workspace }}/.iree-container-cache
-#     MANYLINUX_DOCKER_IMAGE: ghcr.io/iree-org/manylinux_x86_64@sha256:facedb71df670016e74e646d71e869e6fff70d4cdbaa6634d4d0a10d6e174399
+#     MANYLINUX_DOCKER_IMAGE: ghcr.io/iree-org/manylinux_x86_64@sha256:2e0246137819cf10ed84240a971f9dd75cc3eb62dc6907dfd2080ee966b3c9f4
 #     PACKAGE_SUFFIX: "-asserts"
 #   steps:
 #     - name: Prefetch Docker
diff --git a/build_tools/pkgci/build_linux_packages.sh b/build_tools/pkgci/build_linux_packages.sh
index fa89e9c..2bdec3f 100755
--- a/build_tools/pkgci/build_linux_packages.sh
+++ b/build_tools/pkgci/build_linux_packages.sh
@@ -64,7 +64,7 @@
 this_dir="$(cd $(dirname $0) && pwd)"
 script_name="$(basename $0)"
 repo_root=$(cd "${this_dir}" && find_git_dir_parent)
-manylinux_docker_image="${manylinux_docker_image:-$(uname -m | awk '{print ($1 == "aarch64") ? "quay.io/pypa/manylinux_2_28_aarch64" : "ghcr.io/iree-org/manylinux_x86_64@sha256:facedb71df670016e74e646d71e869e6fff70d4cdbaa6634d4d0a10d6e174399" }')}"
+manylinux_docker_image="${manylinux_docker_image:-$(uname -m | awk '{print ($1 == "aarch64") ? "quay.io/pypa/manylinux_2_28_aarch64" : "ghcr.io/iree-org/manylinux_x86_64@sha256:2e0246137819cf10ed84240a971f9dd75cc3eb62dc6907dfd2080ee966b3c9f4" }')}"
 python_versions="${override_python_versions:-cp311-cp311}"
 output_dir="${output_dir:-${this_dir}/wheelhouse}"
 cache_dir="${cache_dir:-}"
diff --git a/build_tools/python_deploy/build_linux_packages.sh b/build_tools/python_deploy/build_linux_packages.sh
index b906c26..def542c 100755
--- a/build_tools/python_deploy/build_linux_packages.sh
+++ b/build_tools/python_deploy/build_linux_packages.sh
@@ -16,7 +16,7 @@
 #   ./build_tools/python_deploy/build_linux_packages.sh
 #
 # Build specific Python versions and packages to custom directory:
-#   override_python_versions="cp39-cp39 cp310-310" \
+#   override_python_versions="cp39-cp39 cp310-cp310" \
 #   packages="iree-runtime" \
 #   output_dir="/tmp/wheelhouse" \
 #   ./build_tools/python_deploy/build_linux_packages.sh
@@ -64,8 +64,8 @@
 this_dir="$(cd $(dirname $0) && pwd)"
 script_name="$(basename $0)"
 repo_root=$(cd "${this_dir}" && find_git_dir_parent)
-manylinux_docker_image="${manylinux_docker_image:-$(uname -m | awk '{print ($1 == "aarch64") ? "quay.io/pypa/manylinux_2_28_aarch64" : "ghcr.io/iree-org/manylinux_x86_64@sha256:facedb71df670016e74e646d71e869e6fff70d4cdbaa6634d4d0a10d6e174399" }')}"
-python_versions="${override_python_versions:-cp39-cp39 cp310-cp310 cp311-cp311 cp312-cp312}"
+manylinux_docker_image="${manylinux_docker_image:-$(uname -m | awk '{print ($1 == "aarch64") ? "quay.io/pypa/manylinux_2_28_aarch64" : "ghcr.io/iree-org/manylinux_x86_64@sha256:2e0246137819cf10ed84240a971f9dd75cc3eb62dc6907dfd2080ee966b3c9f4" }')}"
+python_versions="${override_python_versions:-cp39-cp39 cp310-cp310 cp311-cp311 cp312-cp312 cp313-cp313 cp313-cp313t}"
 output_dir="${output_dir:-${this_dir}/wheelhouse}"
 packages="${packages:-iree-runtime iree-compiler}"
 package_suffix="${package_suffix:-}"
diff --git a/build_tools/python_deploy/install_macos_deps.sh b/build_tools/python_deploy/install_macos_deps.sh
index ec51cde..233ce23 100755
--- a/build_tools/python_deploy/install_macos_deps.sh
+++ b/build_tools/python_deploy/install_macos_deps.sh
@@ -18,10 +18,13 @@
   exit 1
 fi
 
+# These can be discovered at https://www.python.org/downloads/macos/
 PYTHON_SPECS=(
-  3.11@https://www.python.org/ftp/python/3.11.2/python-3.11.2-macos11.pkg
-  3.10@https://www.python.org/ftp/python/3.10.5/python-3.10.5-macos11.pkg
-  3.9@https://www.python.org/ftp/python/3.9.13/python-3.9.13-macos11.pkg
+  3.13@https://www.python.org/ftp/python/3.13.0/python-3.13.0-macos11.pkg
+  3.12@https://www.python.org/ftp/python/3.12.6/python-3.12.6-macos11.pkg
+  3.11@https://www.python.org/ftp/python/3.11.9/python-3.11.9-macos11.pkg
+  # 3.10@https://www.python.org/ftp/python/3.10.5/python-3.10.5-macos11.pkg
+  # 3.9@https://www.python.org/ftp/python/3.9.13/python-3.9.13-macos11.pkg
 )
 
 for python_spec in "${PYTHON_SPECS[@]}"; do
diff --git a/build_tools/python_deploy/install_windows_deps.ps1 b/build_tools/python_deploy/install_windows_deps.ps1
index c3d9187..1e0c365 100644
--- a/build_tools/python_deploy/install_windows_deps.ps1
+++ b/build_tools/python_deploy/install_windows_deps.ps1
@@ -7,19 +7,26 @@
 # Installs dependencies on Windows necessary to build IREE Python wheels.
 
 $PYTHON_VERSIONS = @(
+  "3.13" #,
+  "3.12" #,
   "3.11" #,
   # "3.10",
   # "3.9"
 )
 
 $PYTHON_VERSIONS_NO_DOT = @(
+  "313" #,
+  "312" #,
   "311" #,
   # "310",
   # "39"
 )
 
+# These can be discovered at https://www.python.org/downloads/windows/
 $PYTHON_INSTALLER_URLS = @(
-  "https://www.python.org/ftp/python/3.11.2/python-3.11.2-amd64.exe" #,
+  "https://www.python.org/ftp/python/3.13.0/python-3.13.0-amd64.exe" #,
+  "https://www.python.org/ftp/python/3.12.6/python-3.12.6-amd64.exe" #,
+  "https://www.python.org/ftp/python/3.11.9/python-3.11.9-amd64.exe" #,
   # "https://www.python.org/ftp/python/3.10.5/python-3.10.5-amd64.exe",
   # "https://www.python.org/ftp/python/3.9.13/python-3.9.13-amd64.exe"
 )