Skip to content

Build Wheels

Build Wheels #121

Workflow file for this run

name: Build Wheels
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
inputs:
skip_tests:
description: "Skip cibuildwheel tests"
required: true
type: boolean
os_type:
description: "OS"
default: "all"
type: choice
options:
- macos-latest
- ubuntu-latest
- windows-latest
- all
allow_deploy:
description: "Deploy to PyPI"
required: true
type: boolean
jobs:
test_inplace:
name: Test on ${{ matrix.os }}_${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install Dependencies
run: |
python -m pip install -U pip setuptools
pip install pytest pytest-xdist psutil
- name: Install Project
run: pip install -e .
env:
CYNDILIB_BUILD_PARALLEL: auto
- name: Compile tests
run: |
pip install cython>=0.29.32
python build_tests.py
- name: Run tests
run: py.test
build_wheels:
name: Build wheels on ${{ matrix.os }}_${{ matrix.python-version }}-${{ matrix.arch }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: macos-13
arch: x86_64
python-version: "cp3{8,9,10,11,12}"
- os: macos-14
arch: arm64
python-version: "cp3{8,9,10,11,12}"
- os: ubuntu-latest
arch: x86_64
python-version: "cp3{8,9,10,11,12}"
- os: windows-latest
arch: AMD64
python-version: "cp3{8,9,10,11,12}"
- os: ubuntu-latest
arch: aarch64
python-version: "cp38"
- os: ubuntu-latest
arch: aarch64
python-version: "cp39"
- os: ubuntu-latest
arch: aarch64
python-version: "cp310"
- os: ubuntu-latest
arch: aarch64
python-version: "cp311"
- os: ubuntu-latest
arch: aarch64
python-version: "cp312"
steps:
- uses: actions/checkout@v3
- name: Set up QEMU
if: matrix.os == 'ubuntu-latest'
uses: docker/setup-qemu-action@v2
- uses: actions/setup-python@v5
with:
python-version: 3.8
if: runner.os == 'macOS' && runner.arch == 'ARM64'
- name: Set cibuildwheel env
id: cibuildwheel_env
run: |
CIBW_TEST_SKIP="cp38-macosx*"
if [ "${{ inputs.skip_tests }}" == "true" ]; then
echo "skip_tests is true"
CIBW_TEST_SKIP="*"
fi
echo "test_skip=$CIBW_TEST_SKIP" >> $GITHUB_OUTPUT
shell: bash
- name: Debug env step
run: |
echo "test_skip = ${{ steps.cibuildwheel_env.outputs.test_skip }}"
echo "skip_build = ${{ steps.cibuildwheel_env.outputs.skip_build }}"
shell: bash
- name: Build wheels
id: build_wheel
uses: pypa/[email protected]
env:
CIBW_BUILD: ${{ matrix.python-version }}-*
CIBW_ARCHS: ${{ matrix.arch }}
CIBW_TEST_SKIP: ${{ steps.cibuildwheel_env.outputs.test_skip }}
CIBW_REPAIR_WHEEL_COMMAND_MACOS: "delocate-listdeps {wheel} --all --depending && delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v {wheel}"
if: ${{ inputs.os_type }} != "" && (${{ inputs.os_type }} == matrix.os || ${{ inputs.os_type }} == "all")
# ...
# with:
# package-dir: .
# output-dir: wheelhouse
# config-file: "{package}/pyproject.toml"
- uses: actions/upload-artifact@v3
if: ${{ steps.build_wheel.outcome }} == "success"
with:
path: ./wheelhouse/*.whl
deploy:
name: 'Deploy to PyPI'
needs: [test_inplace, build_wheels]
runs-on: ubuntu-latest
if: ${{ inputs.allow_deploy }}
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v3
with:
name: artifact
path: dist
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1