Skip to content
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
41 changes: 40 additions & 1 deletion .github/workflows/build-wheels-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ on:
Python version:
required: true
type: string
canonical_python:
description: |
Python version on which build.sh (py3-none) recipes are built; other legs
skip them as identical duplicates. Empty = no gating (build everything).
required: false
type: string
default: ""
archs:
description: |
Architectures (comma-separated):
Expand Down Expand Up @@ -57,6 +64,12 @@ on:
- "3.13"
- "3.14"
default: "3.12"
canonical_python:
description: |
Python version on which build.sh (py3-none) recipes are built; other legs
skip them. Leave empty for a standalone dispatch (no gating):
required: false
default: ""
archs:
description: |
Architectures (comma-separated):
Expand Down Expand Up @@ -101,6 +114,7 @@ jobs:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
has_jobs: ${{ steps.set-matrix.outputs.has_jobs }}
steps:
- name: Checkout
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
Expand All @@ -116,16 +130,32 @@ jobs:
INPUT_ARCHS: ${{ inputs.archs }}
INPUT_PACKAGES: ${{ inputs.packages }}
INPUT_PYTHON_VERSION: ${{ inputs.python_version }}
INPUT_CANONICAL_PYTHON: ${{ inputs.canonical_python }}
run: |
ARCHS="$INPUT_ARCHS"
PACKAGES="$INPUT_PACKAGES"
py="$INPUT_PYTHON_VERSION"
py_short="$(echo "$py" | cut -d. -f1-2)" # 3.12 or 3.12.13 -> 3.12
canonical="$INPUT_CANONICAL_PYTHON" # empty => no gating

# build.sh recipes -> py3-none wheels, identical on every leg, so build them
# only on the canonical one. Decided once per package, before the arch x platform
# expansion (so each skip logs once; the survivors may be empty).
build_packages=""
for pkg in $(echo "$PACKAGES" | tr ',' ' '); do
pkg_name="${pkg%%:*}"
if [[ -n "$canonical" && "$py_short" != "$canonical" \
&& -f "recipes/$pkg_name/build.sh" ]]; then
echo "::notice::Skip py${py_short}: ${pkg_name} — py3-none recipe, built only on py${canonical}"
continue
fi
build_packages="${build_packages:+$build_packages }$pkg"
done

matrix='{"include":['
first=true
for arch in $(echo "$ARCHS" | tr ',' ' '); do
for pkg in $(echo "$PACKAGES" | tr ',' ' '); do
for pkg in $build_packages; do
pkg_name="${pkg%%:*}"
if [[ "$arch" == "android" ]]; then
runner="ubuntu-latest"
Expand Down Expand Up @@ -163,8 +193,17 @@ jobs:
matrix+=']}'
echo "matrix=$matrix" >> "$GITHUB_OUTPUT"

# An all-py3-none non-canonical leg yields an empty include; flag it so the
# build job is skipped rather than fed an empty matrix.
if [[ "$matrix" == '{"include":[]}' ]]; then
echo "has_jobs=false" >> "$GITHUB_OUTPUT"
else
echo "has_jobs=true" >> "$GITHUB_OUTPUT"
fi

build:
needs: setup
if: ${{ needs.setup.outputs.has_jobs == 'true' }} # Skip legs with no jobs (e.g. an all-py3-none non-canonical leg).
name: ${{ matrix.job_name }}
runs-on: ${{ matrix.runner }}
strategy:
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/build-wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ jobs:
runs-on: ubuntu-latest
outputs:
pythons_json: ${{ steps.detect-pythons.outputs.pythons_json }}
canonical_python: ${{ steps.detect-pythons.outputs.canonical_python }}
packages: ${{ steps.detect-packages.outputs.packages }}
steps:
- name: Checkout
Expand Down Expand Up @@ -125,6 +126,11 @@ jobs:
echo "Detected pythons: $pythons -> $json"
echo "pythons_json=$json" >> "$GITHUB_OUTPUT"

# Canonical leg = first listed Python. build.sh (py3-none) recipes are
# identical on every leg, so they build only on the canonical one.
canonical="$(echo "$pythons" | tr ',' ' ' | awk '{print $1}' | cut -d. -f1-2)"
echo "canonical_python=$canonical" >> "$GITHUB_OUTPUT"

- id: detect-packages
shell: bash
env:
Expand Down Expand Up @@ -167,6 +173,7 @@ jobs:
uses: ./.github/workflows/build-wheels-version.yml
with:
python_version: ${{ matrix.python_version }}
canonical_python: ${{ needs.detect.outputs.canonical_python }}
archs: ${{ inputs.archs || 'android,iOS' }}
packages: ${{ needs.detect.outputs.packages }}
prebuild_recipes: ${{ inputs.prebuild_recipes || '' }}
Expand Down
Loading