From 7fe341a3a0bdf2563efe0a3e82b4c3064b4c87cc Mon Sep 17 00:00:00 2001 From: Haoran Du Date: Mon, 12 Oct 2026 17:13:03 +0800 Subject: [PATCH 1/4] Build release wheels only for 64-bit Python --- pyproject.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 5180744a..dc573987 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -176,6 +176,8 @@ exclude_lines = ["pragma: no cover", "if TYPE_CHECKING:"] # test-command = "pytest" build = ["cp38-*", "cp39-*", "cp310-*", "cp311-*", "cp312-*", "cp313-*", "cp314-*", "cp315-*"] +# PyTorch and the scientific dependencies require 64-bit Python wheels. +archs = "auto64" test-command = "python {project}/scripts/wheel_smoke.py" # Skip building free-threaded compatible wheels on Windows From 7208163df171e64f5abe0c67134b1e69ea4e6e79 Mon Sep 17 00:00:00 2001 From: Haoran Du Date: Mon, 12 Oct 2026 17:16:00 +0800 Subject: [PATCH 2/4] Restrict PyPI uploads to the release branch --- .github/workflows/wheel_publish.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/wheel_publish.yml b/.github/workflows/wheel_publish.yml index b277d4e4..8ffc8d20 100644 --- a/.github/workflows/wheel_publish.yml +++ b/.github/workflows/wheel_publish.yml @@ -67,6 +67,7 @@ jobs: upload_pypi: needs: [build_wheels, build_sdist] + if: github.ref == 'refs/heads/pybind11' runs-on: ubuntu-latest environment: pypi permissions: From e3694f47f4b53d7edc6fb3e41440b384d6fe2271 Mon Sep 17 00:00:00 2001 From: Haoran Du Date: Mon, 12 Oct 2026 17:33:22 +0800 Subject: [PATCH 3/4] Use compatible Linux wheel test environments --- pyproject.toml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index dc573987..21b9235f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -180,8 +180,15 @@ build = ["cp38-*", "cp39-*", "cp310-*", "cp311-*", "cp312-*", "cp313-*", "cp314- archs = "auto64" test-command = "python {project}/scripts/wheel_smoke.py" -# Skip building free-threaded compatible wheels on Windows -skip = "*t-win*" +# Legacy musllinux targets lack wheels for the required scientific dependencies. +skip = "*t-win* cp3{8,9,10,11,12,13}-musllinux_*" + +[tool.cibuildwheel.linux] +environment = { PIP_EXTRA_INDEX_URL = "https://download.pytorch.org/whl/cpu" } + +[[tool.cibuildwheel.overrides]] +select = "cp3{9,10,11,12,13}-manylinux_*" +manylinux-x86_64-image = "manylinux_2_28" From 41a97ac631027b717399d74ce46cd89bcc43899a Mon Sep 17 00:00:00 2001 From: Haoran Du Date: Mon, 12 Oct 2026 20:50:01 +0800 Subject: [PATCH 4/4] Allow publishing successful wheel artifacts without rebuilding --- .github/workflows/wheel_publish.yml | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/.github/workflows/wheel_publish.yml b/.github/workflows/wheel_publish.yml index 8ffc8d20..68f5dd7c 100644 --- a/.github/workflows/wheel_publish.yml +++ b/.github/workflows/wheel_publish.yml @@ -1,8 +1,15 @@ name: Build,download and publish wheels -on: workflow_dispatch +on: + workflow_dispatch: + inputs: + artifact_run_id: + description: Successful wheel run to publish without rebuilding (leave empty to build) + required: false + type: string jobs: build_sdist: name: Build source distribution + if: inputs.artifact_run_id == '' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -19,6 +26,7 @@ jobs: build_wheels: name: Build wheels on ${{ matrix.os }} + if: inputs.artifact_run_id == '' runs-on: ${{ matrix.os }} strategy: matrix: @@ -67,18 +75,34 @@ jobs: upload_pypi: needs: [build_wheels, build_sdist] - if: github.ref == 'refs/heads/pybind11' + if: >- + always() && + ((github.ref == 'refs/heads/pybind11' && needs.build_wheels.result == 'success' && needs.build_sdist.result == 'success') || inputs.artifact_run_id != '') runs-on: ubuntu-latest environment: pypi permissions: id-token: write + actions: read steps: + - name: Verify the reused wheel run succeeded + if: inputs.artifact_run_id != '' + env: + GH_TOKEN: ${{ github.token }} + GH_REPO: ${{ github.repository }} + RUN_ID: ${{ inputs.artifact_run_id }} + run: | + [[ "$RUN_ID" =~ ^[0-9]+$ ]] || exit 1 + gh api "repos/$GH_REPO/actions/runs/$RUN_ID" \ + --jq '.status == "completed" and .conclusion == "success" and .path == ".github/workflows/wheel_publish.yml"' | grep -qx true + - uses: actions/download-artifact@v4 with: # unpacks all CIBW artifacts into dist/ pattern: cibw-* path: dist merge-multiple: true + run-id: ${{ inputs.artifact_run_id || github.run_id }} + github-token: ${{ github.token }} - name: Publish distribution 📦 to PyPI uses: pypa/gh-action-pypi-publish@v1.12.4