π Fix wheel build #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://github.com/pybind/scikit_build_example/blob/master/.github/workflows/wheels.yml | |
name: Wheels | |
on: | |
push: | |
branches: | |
- main | |
release: | |
types: | |
- published | |
env: | |
FORCE_COLOR: 3 | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
build_sdist: | |
name: Build SDist | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Set up JDK 21 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: '21' | |
- name: Build SDist | |
run: pipx run build --sdist | |
- name: Check metadata | |
run: pipx run twine check dist/* | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: cibw-sdist | |
path: dist/*.tar.gz | |
build_wheels: | |
name: Wheels on ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
# macos-13 is an intel runner, macos-14 is apple silicon | |
os: [ubuntu-latest, macos-latest, windows-latest] # macos-13, macos-14 makes corrupt zip | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Set up JDK 21 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: '21' | |
- uses: astral-sh/setup-uv@v4 | |
- name: install pytorch headers if macos # export CMAKE_PREFIX_PATH=$LIBTORCH | |
if: matrix.os == 'macos-latest' | |
run: | | |
curl -LO https://download.pytorch.org/libtorch/cpu/libtorch-macos-arm64-2.5.1.zip | |
unzip libtorch-macos-arm64-2.5.1.zip | |
export LIBTORCH=/usr/local/libtorch | |
mv libtorch-macos-arm64-2.5.1 $LIBTORCH | |
- name: Build wheels | |
uses: pypa/[email protected] | |
env: | |
CIBW_SKIP: cp36-* cp37-* cp38-* | |
CIBW_ENABLE: cpython-prerelease | |
CIBW_ARCHS_WINDOWS: "AMD64 x86" | |
CIBW_ARCHS_MACOS: "x86_64 universal2 arm64" | |
CIBW_ARCHS_LINUX: "x86_64" | |
- name: Verify clean directory | |
run: git diff --exit-code | |
shell: bash | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: cibw-wheels-${{ matrix.os }} | |
path: wheelhouse/*.whl | |
upload_all: | |
name: Upload if release | |
needs: [build_wheels, build_sdist] | |
runs-on: ubuntu-latest | |
if: github.event_name == 'release' && github.event.action == 'published' | |
environment: pypi | |
permissions: | |
id-token: write | |
attestations: write | |
steps: | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: "3.9" | |
- uses: actions/download-artifact@v4 | |
with: | |
pattern: cibw-* | |
merge-multiple: true | |
path: dist | |
- name: Generate artifact attestation for sdist and wheels | |
uses: actions/attest-build-provenance@v1 | |
with: | |
subject-path: "dist/*" | |
- uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
attestations: true |