Skip to content

Build Python wheels #16

Build Python wheels

Build Python wheels #16

Workflow file for this run

name: Build Python wheels
on:
workflow_dispatch:
inputs:
upload:
description: 'Upload wheels to PyPI? (0: no, 1: yes)'
required: true
default: '0'
env:
CIBW_TEST_COMMAND: "python -c \"import mitsuba\""
CIBW_BEFORE_TEST: "python -m pip install --index-url https://test.pypi.org/simple/ throwaway8213fork"
CIBW_TEST_REQUIRES: ""
CIBW_REPAIR_WHEEL_COMMAND_LINUX: "python .github/workflows/tag_wheel_manylinux.py {wheel} {dest_dir}"
CIBW_REPAIR_WHEEL_COMMAND_MACOS: "delocate-wheel --require-archs {delocate_archs} -w {dest_dir} --ignore-missing-dependencies {wheel}"
jobs:
build_wheels:
strategy:
matrix:
os: [ubuntu-20.04, windows-latest, macos-13, macos-14]
python: [cp38, cp39, cp310, cp311, cp312, cp313, cp313_stable]
exclude:
# The first Python version to target Apple arm64 architectures is 3.9
- os: macos-14
python: cp38
fail-fast: false
name: >
${{ matrix.python }} wheel for ${{ matrix.os }}
${{ (endsWith(matrix.python, '_stable') && '(stable ABI)') || '' }}
runs-on: ${{ matrix.os }}
steps:
###########################################################
# Setup local environment (source code, build requirements)
###########################################################
- uses: Wandalen/[email protected]
with:
action: actions/checkout@v3
with: |
submodules: recursive
attempt_limit: 3
attempt_delay: 2000
- uses: actions/setup-python@v4
name: Install Python
with:
python-version: '3.10'
- name: Prepare compiler environment for Windows
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@v1
with:
arch: x64
- name: Install cibuildwheel
run: |
python -m pip install cibuildwheel==2.20.0
################################################################
# Set up envvars to build the correct wheel (stable ABI or not)
################################################################
- name: Prepare cibuildwheel environment (UNIX)
if: ${{ ! endsWith(matrix.python, '_stable') && runner.os != 'Windows' }}
run: |
echo "CIBW_BUILD=${{ matrix.python }}-*" >> $GITHUB_ENV
- name: Prepare cibuildwheel environment (Windows)
if: ${{ ! endsWith(matrix.python, '_stable') && runner.os == 'Windows' }}
run: |
echo "CIBW_BUILD=${{ matrix.python }}-*" >> $env:GITHUB_ENV
- name: Prepare cibuildwheel environment for stable ABI wheel (UNIX)
if: ${{ endsWith(matrix.python, '_stable') && runner.os != 'Windows' }}
run: |
stable_cp=$(echo ${{ matrix.python }} | cut -d_ -f1) &&
echo "CIBW_BUILD=${stable_cp}-*" >> $GITHUB_ENV &&
echo "CIBW_CONFIG_SETTINGS=\"wheel.py-api=cp312\" \"cmake.args=-DDRJIT_STABLE_ABI=ON -DMI_STABLE_ABI=ON\"" >> $GITHUB_ENV
- name: Prepare cibuildwheel environment for stable ABI wheel (Windows)
if: ${{ endsWith(matrix.python, '_stable') && runner.os == 'Windows' }}
run: |
$stable_cp = '${{ matrix.python }}' -split '_'
echo "CIBW_BUILD=$($stable_cp[0])-*" >> $env:GITHUB_ENV
echo "CIBW_CONFIG_SETTINGS=wheel.py-api=cp312 cmake.args=-DDRJIT_STABLE_ABI=ON -DMI_STABLE_ABI=ON" >> $env:GITHUB_ENV
#########################
# Build and store wheels
#########################
- name: Build wheel
run: |
python -m cibuildwheel --output-dir wheelhouse
- uses: actions/upload-artifact@v3
with:
name: wheels
path: ./wheelhouse/*.whl
upload_pypi:
name: Upload wheels to PyPI
runs-on: ubuntu-latest
if: ${{ github.event.inputs.upload == '1'}}
needs: [build_wheels]
steps:
#########################
# Fetch and upload wheels
#########################
- uses: actions/download-artifact@v3
with:
name: wheels
path: dist
- uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.PYPI_PASSWORD }}