Build Python wheels #29
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
name: Build Python wheels | |
on: | |
workflow_dispatch: | |
inputs: | |
upload: | |
description: 'Upload wheels to PyPI? (0: no, 1: yes)' | |
required: true | |
default: '0' | |
env: | |
CIBW_BUILD_VERBOSITY: 1 | |
CIBW_SKIP: "*-musllinux* pp*" | |
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014 | |
CIBW_ARCHS_WINDOWS: auto64 | |
CIBW_ARCHS_LINUX: auto64 | |
CIBW_BEFORE_BUILD_LINUX: yum install -y libatomic | |
CIBW_TEST_COMMAND: "python -c \"import drjit\"" | |
CIBW_TEST_SKIP: "*-macosx_arm64" | |
MACOSX_DEPLOYMENT_TARGET: 10.14 | |
jobs: | |
build_wheels: | |
strategy: | |
matrix: | |
os: [ubuntu-20.04, windows-latest, macos-latest] | |
python: [cp38, cp39, cp310, cp311] | |
cibw-arch: [x86_64, arm64] | |
exclude: | |
- os: ubuntu-20.04 | |
cibw-arch: arm64 | |
- os: windows-latest | |
cibw-arch: arm64 | |
fail-fast: false | |
name: > | |
${{ matrix.python }} wheel for ${{ matrix.os }} | |
${{ (matrix.os == 'macos-latest' && format('({0})', matrix.cibw-arch)) || '' }} | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: Wandalen/wretry.action@v1.2.0 | |
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.11.2 | |
- name: Local build for macOS cross-compilation | |
if: runner.os == 'macOS' && matrix.cibw-arch == 'arm64' | |
run: | | |
pip install ninja cmake | |
mkdir build | |
cmake -B build -GNinja . | |
ninja -C build drjit_stub_file_generation | |
- name: Prepare cibuildwheel environment for macOS | |
if: runner.os == 'macOS' | |
run: | | |
[[ "arm64" == "${{ matrix.cibw-arch }}" ]] && \ | |
echo "DRJIT_CMAKE_TOOLCHAIN_FILE=$(pwd)/.github/workflows/macOS_arm64_toolchain.cmake" >> $GITHUB_ENV && \ | |
echo "DRJIT_PYTHON_STUBS_DIR=$(pwd)/build/drjit" >> $GITHUB_ENV | |
echo "CIBW_ARCHS_MACOS=${{ matrix.cibw-arch }}" >> $GITHUB_ENV | |
- name: Build wheels | |
env: | |
CIBW_BUILD: ${{ matrix.python }}-* | |
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: | |
- uses: actions/download-artifact@v2 | |
with: | |
name: wheels | |
path: dist | |
- uses: pypa/gh-action-pypi-publish@v1.5.1 | |
with: | |
user: __token__ | |
password: ${{ secrets.PYPI_PASSWORD }} |