Skip to content

More binary builds v2 #85

More binary builds v2

More binary builds v2 #85

Workflow file for this run

# Github Actions script to produce binary wheels.
#
# We perform one build for each wheel that we generate, i.e. one per architecture.
# In download_wgpu_native.py, we detect CIBW_PLATFORM and CIBW_ARCHS to determine
# the required binary from wgpu-native.
#
# If https://github.com/pypa/cibuildwheel/issues/944 gets implemented, we can build more wheels per build.
#
# Also includes the sdist build that does not include a binary.
name: CD
on:
workflow_dispatch:
push:
tags:
- 'v*'
pull_request:
branches:
- main
jobs:
release-builds:
name: Build wheel for ${{ matrix.platform }} ${{ matrix.arch }}
timeout-minutes: 10
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- platform: windows
arch: AMD64
os: windows-latest
testable: true
- platform: windows
arch: ARM64
os: windows-latest
- platform: windows
arch: x86
os: windows-latest
- platform: macos
arch: arm64
os: macos-latest
testable: true
- platform: macos
arch: x86_64
os: macos-13 # latest Intel MacOS
cibw_version: '==2.16' # delocation does not work for later versions
- platform: linux
arch: x86_64
os: ubuntu-latest
testable: true
- platform: linux
arch: aarch64
os: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up QEMU
if: matrix.platform == 'linux' && matrix.arch == 'aarch64'
uses: docker/setup-qemu-action@v3
with:
platforms: arm64
- name: Install dev dependencies
run: |
python -m pip install --upgrade pip wheel setuptools twine cibuildwheel${{ matrix.cibw_version}}
- name: Build wheels
run: python -m cibuildwheel --output-dir dist
env:
CIBW_PLATFORM: ${{ matrix.platform }}
CIBW_ARCHS: ${{ matrix.arch }}
- name: Twine check
run: |
twine check dist/*
- name: Test wheel
if: matrix.testable
shell: bash
run: |
rm -rf ./wgpu
python -m pip install cffi
python -m pip install --no-index --no-dependencies --find-links dist wgpu
pushd $HOME
python -c 'import wgpu.backends.wgpu_native; print(wgpu.backends.wgpu_native._ffi.lib_path)'
# cleanup
popd
pip uninstall -y wgpu
git reset --hard HEAD
- name: Upload distributions
uses: actions/upload-artifact@v4
with:
path: dist
name: ${{ matrix.platform }}-${{ matrix.arch }}-build
sdist-build:
name: Build sdist
timeout-minutes: 5
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install dev dependencies
run: |
python -m pip install --upgrade pip
pip install -U -r dev-requirements.txt
- name: Create source distribution
run: |
python setup.py sdist
- name: Test sdist
shell: bash
run: |
rm -rf ./wgpu
python -m pip install --no-index --no-dependencies --find-links dist wgpu
# don't run tests, we just want to know if the sdist can be installed
pip uninstall -y wgpu
git reset --hard HEAD
- name: Twine check
run: |
twine check dist/*
- name: Upload distributions
uses: actions/upload-artifact@v4
with:
path: dist
name: sdist-build
publish:
name: Publish to Github and Pypi
runs-on: ubuntu-latest
needs: [release-builds, sdist-build]
if: success() && startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Download assets
uses: actions/download-artifact@v4
with:
path: dist
- name: Flatten dist dir
run: |
find dist -mindepth 2 -type f -exec mv -f '{}' dist/ ';'
rm -rf dist/*/
- name: Set version from git ref
run: echo "WGPU_PY_VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
- name: Upload Release Assets
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.WGPU_PY_VERSION }}
name: ${{ env.WGPU_PY_VERSION }}
token: ${{ secrets.GITHUB_TOKEN }}
files: |
dist/*.tar.gz
dist/*.whl
body: |
Autogenerated binary wheels that include wgpu-native.
See [the changelog](https://github.com/pygfx/wgpu-py/blob/main/CHANGELOG.md) for details.
draft: false
prerelease: false
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_PASSWORD }}