wheels #82
Workflow file for this run
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: wheels | |
on: | |
workflow_dispatch: | |
inputs: | |
# Manual dispatch allows optional upload of wheels to PyPI | |
upload_dest: | |
type: choice | |
description: Upload wheels to | |
options: | |
- No Upload | |
- PyPI | |
- Test PyPI | |
release: | |
types: | |
- published | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
permissions: | |
# For PyPI Trusted Publisher | |
id-token: write | |
jobs: | |
build_sdist: | |
name: Build SDist | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Build SDist | |
# Our Python package is in the python/ subdirectory. | |
# Also, the fast_matrix_market C++ library is symlinked. The build tool ignores the symlinks, so | |
# replace the symlinks with their targets so that they get included in the sdist. | |
run: | | |
cd python/ | |
cd fast_matrix_market/ | |
for LINK in *; do DEST="$(readlink -f $LINK)"; rm -rf $LINK; cp -r $DEST .; done; | |
cd .. | |
pipx run build --sdist | |
cd .. | |
shell: bash | |
- name: Check metadata | |
run: pipx run twine check python/dist/* | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: sdist | |
path: python/dist/*.tar.gz | |
build_wheels: | |
name: Wheels on ${{ matrix.os }} - ${{ matrix.cibw_archs }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
# Originally based on scikit-learn's config, but has diverged since: | |
# https://github.com/scikit-learn/scikit-learn/blob/main/.github/workflows/wheels.yml | |
include: | |
# - os: windows-latest | |
# cibw_archs: "AMD64" | |
- os: ubuntu-latest | |
cibw_archs: "x86_64" | |
# TODO:remove: | |
cibw_skip: "cp37* cp38* cp31* pp* *musl*" | |
# - os: ubuntu-latest | |
# cibw_archs: "aarch64" | |
# # numpy wheels not available for aarch64 PyPy or musllinux | |
# cibw_skip: "pp* *musl*" | |
- os: macos-latest | |
cibw_archs: "x86_64" | |
# TODO:remove: | |
cibw_skip: "cp37* cp38* cp31* pp* *musl*" | |
- os: macos-latest | |
cibw_archs: "arm64" | |
# Skip macOS ARM tests on Intel runner. | |
cibw_test_skip: "*-macosx_arm64" | |
# TODO:remove: | |
cibw_skip: "cp37* cp38* cp31* pp* *musl*" | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup QEMU | |
# for building non-x86 Linux wheels on x86 runner | |
if: runner.os == 'Linux' | |
uses: docker/setup-qemu-action@v3 | |
with: | |
platforms: all | |
- uses: pypa/cibuildwheel@v2.16 | |
with: | |
package-dir: python | |
output-dir: wheelhouse | |
env: | |
CIBW_BUILD_VERBOSITY: 3 | |
CIBW_ARCHS: ${{ matrix.cibw_archs }} | |
CIBW_SKIP: ${{ matrix.cibw_skip }} | |
CIBW_TEST_SKIP: ${{ matrix.cibw_test_skip }} | |
# Allow pre-release to test on newest Python that may only have beta or RC numpy packages available. | |
# --only-binary and ' || true' to best-effort numpy and scipy installation. | |
# Some platforms do not have binary wheels for either package, some only for numpy. | |
# Notably PyPy: no scipy wheels, and numpy wheels for only some versions. | |
CIBW_BEFORE_TEST: pip install --pre --only-binary ":all:" numpy && pip install --pre --only-binary ":all:" scipy || true | |
# make cibuildwheel install test dependencies from pyproject.toml | |
CIBW_TEST_EXTRAS: "testmin" | |
# run tests in the {package}/tests dir which is python/tests | |
CIBW_TEST_COMMAND: "pytest {package}/tests" | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: wheels-${{ matrix.os }}-${{ matrix.cibw_archs }} | |
path: wheelhouse/*.whl | |
upload_all: | |
name: Upload to PyPI | |
needs: [build_wheels, build_sdist] | |
runs-on: ubuntu-latest | |
if: (github.event_name == 'release' && github.event.action == 'published') || (github.event_name == 'workflow_dispatch' && github.event.inputs.upload_dest != 'No Upload') | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
path: dist_artifacts | |
- name: Display structure of downloaded files | |
run: ls -R dist_artifacts | |
- name: Flatten artifacts to dist/ | |
run: mkdir dist && find dist_artifacts -type f -exec mv {} dist \; | |
- name: Display structure of downloaded files | |
run: ls -R dist | |
# # Upload to PyPI | |
# - uses: pypa/gh-action-pypi-publish@release/v1 | |
# name: Upload to PyPI | |
# if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.event.inputs.upload_dest == 'PyPI') | |
# with: | |
# # PyPI does not allow replacing a file. Without this flag the entire action fails if even a single duplicate exists. | |
# skip-existing: true | |
# verbose: true | |
# password: ${{ secrets.PYPI_API_TOKEN }} | |
# | |
# Upload to Test PyPI | |
- uses: pypa/gh-action-pypi-publish@release/v1 | |
name: Upload to Test PyPI | |
if: github.event_name == 'workflow_dispatch' && github.event.inputs.upload_dest == 'Test PyPI' | |
with: | |
# PyPI does not allow replacing a file. Without this flag the entire action fails if even a single duplicate exists. | |
skip-existing: true | |
verbose: true | |
repository-url: https://test.pypi.org/legacy/ |