From 414d7d59d329cf7af9db23d7e7fb2cbbba06ee15 Mon Sep 17 00:00:00 2001 From: ndonkoHenri Date: Sun, 28 Jun 2026 18:05:40 +0200 Subject: [PATCH 1/2] initial commit --- .github/workflows/build-wheels-version.yml | 16 ++++++++++++++++ .github/workflows/build-wheels.yml | 2 ++ 2 files changed, 18 insertions(+) diff --git a/.github/workflows/build-wheels-version.yml b/.github/workflows/build-wheels-version.yml index d6a623ff..e22083be 100644 --- a/.github/workflows/build-wheels-version.yml +++ b/.github/workflows/build-wheels-version.yml @@ -8,6 +8,15 @@ on: Python version: required: true type: string + canonical_python: + description: | + The single Python version on which Python-independent recipes (those with a + build.sh -> py3-none- wheel) are built. On any other leg those recipes + are skipped, since their wheels are identical across versions and the extra + legs only emit publish-time duplicates. Empty = no gating (build everything). + required: false + type: string + default: "" archs: description: | Architectures (comma-separated): @@ -57,6 +66,13 @@ on: - "3.13" - "3.14" default: "3.12" + canonical_python: + description: | + The single Python version on which Python-independent recipes (those with a + build.sh -> py3-none- wheel) are built. Leave empty for a standalone + dispatch (no gating — build every recipe on this version): + required: false + default: "" archs: description: | Architectures (comma-separated): diff --git a/.github/workflows/build-wheels.yml b/.github/workflows/build-wheels.yml index 051131bf..bbc915f6 100644 --- a/.github/workflows/build-wheels.yml +++ b/.github/workflows/build-wheels.yml @@ -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 @@ -167,6 +168,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 || '' }} From 0cadd9d8f1a23a3de848f8e14a5b3d0c62058156 Mon Sep 17 00:00:00 2001 From: ndonkoHenri Date: Sun, 28 Jun 2026 18:12:21 +0200 Subject: [PATCH 2/2] improve --- .github/workflows/build-wheels-version.yml | 39 +++++++++++++++++----- .github/workflows/build-wheels.yml | 5 +++ 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build-wheels-version.yml b/.github/workflows/build-wheels-version.yml index e22083be..c156040f 100644 --- a/.github/workflows/build-wheels-version.yml +++ b/.github/workflows/build-wheels-version.yml @@ -10,10 +10,8 @@ on: type: string canonical_python: description: | - The single Python version on which Python-independent recipes (those with a - build.sh -> py3-none- wheel) are built. On any other leg those recipes - are skipped, since their wheels are identical across versions and the extra - legs only emit publish-time duplicates. Empty = no gating (build everything). + 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: "" @@ -68,9 +66,8 @@ on: default: "3.12" canonical_python: description: | - The single Python version on which Python-independent recipes (those with a - build.sh -> py3-none- wheel) are built. Leave empty for a standalone - dispatch (no gating — build every recipe on this version): + 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: @@ -117,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 @@ -132,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" @@ -179,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: diff --git a/.github/workflows/build-wheels.yml b/.github/workflows/build-wheels.yml index bbc915f6..e519714a 100644 --- a/.github/workflows/build-wheels.yml +++ b/.github/workflows/build-wheels.yml @@ -126,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: