Use cibuildwheel
for all architectures; add support for aarch64
linux; publish musllinux
wheels as well as manylinux
; move cibuildwheel
configuration to pyproject.toml
; use pypa action for PyPI upload
#329
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 | |
on: | |
pull_request: | |
push: | |
branches: | |
- master | |
tags: | |
- '*' | |
jobs: | |
cleanup-runs: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: rokroskar/workflow-run-cleanup-action@master | |
env: | |
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | |
if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/master'" | |
build_openmp: | |
runs-on: ${{ matrix.os }} | |
defaults: | |
run: | |
shell: bash -l {0} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ ubuntu-latest ] | |
python-version: [ 3.8, 3.9, "3.10", "3.11" ] | |
env: | |
PYTHON_VERSION: ${{ matrix.python-version }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- uses: conda-incubator/setup-miniconda@v3 | |
with: | |
auto-update-conda: true | |
python-version: ${{ matrix.python-version }} | |
miniforge-version: latest | |
channels: conda-forge,anaconda | |
- name: Install dependencies | |
run: | | |
conda install scipy numpy pytest 'setuptools<=60' | |
- name: Test | |
run: | | |
python legacy_setup.py install --scs --openmp | |
pytest | |
rm -rf build/ | |
build_mkl: | |
runs-on: ${{ matrix.os }} | |
defaults: | |
run: | |
shell: bash -l {0} | |
strategy: | |
fail-fast: false | |
matrix: | |
# macos-13 runners have intel chips. macos-14 and above | |
# runners have Apple silicon chips. | |
os: [ ubuntu-latest, macos-13, windows-latest ] | |
python-version: [ 3.8, 3.9, "3.10", "3.11", "3.12"] | |
link_mkl: [true] | |
env: | |
PYTHON_VERSION: ${{ matrix.python-version }} | |
LINK_MKL: ${{ matrix.link_mkl }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Set Additional Envs | |
shell: bash | |
run: | | |
echo "DEPLOY=$( [[ $GITHUB_EVENT_NAME == 'push' && $GITHUB_REF == 'refs/tags'* ]] && echo 'True' || echo 'False' )" >> $GITHUB_ENV | |
echo "PYTHON_SUBVERSION=$(echo $PYTHON_VERSION | cut -c 3-)" >> $GITHUB_ENV | |
- uses: conda-incubator/setup-miniconda@v3 | |
with: | |
auto-update-conda: true | |
python-version: ${{ matrix.python-version }} | |
miniforge-version: latest | |
channels: conda-forge,anaconda | |
- name: Install dependencies | |
run: | | |
if [[ "$LINK_MKL" == "true" ]]; then | |
BLAS_PKGS="blas-devel=*=*mkl" | |
else | |
BLAS_PKGS="blas-devel=*=*openblas" | |
fi | |
if [[ "$PYTHON_VERSION" == "3.8" ]]; then | |
conda install scipy=1.5 numpy=1.19 pytest $BLAS_PKGS pkg-config 'setuptools<=60' | |
elif [[ "$PYTHON_VERSION" == "3.9" ]]; then | |
conda install scipy=1.5 numpy=1.19 pytest $BLAS_PKGS pkg-config | |
elif [[ "$PYTHON_VERSION" == "3.10" ]]; then | |
conda install scipy=1.7 numpy=1.21 pytest $BLAS_PKGS pkg-config | |
elif [[ "$PYTHON_VERSION" == "3.11" ]]; then | |
conda install scipy=1.9.3 numpy=1.23.4 pytest $BLAS_PKGS pkg-config | |
elif [[ "$PYTHON_VERSION" == "3.12" ]]; then | |
conda install scipy numpy pytest $BLAS_PKGS pkg-config | |
fi | |
- name: Build | |
run: | | |
if [[ "$PYTHON_VERSION" == "3.8" ]]; then | |
if [[ "$LINK_MKL" == "true" ]]; then | |
python legacy_setup.py install --scs --mkl | |
else | |
python legacy_setup.py install | |
fi | |
elif [[ "$PYTHON_VERSION" != "3.8" ]]; then | |
python -c "import numpy as np; print('NUMPY BLAS INFOS'); print(np.show_config())" | |
if [[ "$LINK_MKL" == "true" ]]; then | |
python -m pip install --verbose -Csetup-args=-Dlink_mkl=true . | |
else | |
python -m pip install --verbose . | |
fi | |
fi | |
- name: Test | |
run: | | |
pytest | |
rm -rf build/ | |
# from here to end it's a copy-paste, with few changes, of | |
# https://github.com/pypa/cibuildwheel/blob/main/examples/github-deploy.yml | |
build_wheels: | |
name: Build wheels on ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
# macos-13 is an intel runner, macos-14 is apple silicon | |
os: [ubuntu-latest, macos-14, windows-latest, macos-13] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Set up QEMU for aarch64 compilation on Linux | |
if: runner.os == 'Linux' | |
uses: docker/setup-qemu-action@v3 | |
with: | |
platforms: all | |
- name: Install conda on Windows | |
if: runner.os == 'Windows' | |
uses: conda-incubator/setup-miniconda@v3 | |
with: | |
miniconda-version: "latest" | |
channels: conda-forge, anaconda | |
- name: Install openblas from conda on Windows | |
if: runner.os == 'Windows' | |
run: conda install -y openblas pkgconfig | |
- name: Build wheels | |
uses: pypa/[email protected] | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} | |
path: ./wheelhouse/*.whl | |
build_sdist: | |
name: Build source distribution | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Build sdist | |
run: pipx run build --sdist | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: cibw-sdist | |
path: dist/*.tar.gz | |
upload_pypi: | |
needs: [build_wheels, build_sdist] | |
runs-on: ubuntu-latest | |
environment: pypi | |
permissions: | |
id-token: write | |
if: github.event_name == 'release' && github.event.action == 'published' | |
# or, alternatively, upload to PyPI on every tag starting with 'v' (remove on: release above to use this) | |
# if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
# unpacks all CIBW artifacts into dist/ | |
pattern: cibw-* | |
path: dist | |
merge-multiple: true | |
- uses: pypa/gh-action-pypi-publish@release/v1 | |
# To test: | |
# with: | |
# repository-url: https://test.pypi.org/legacy/ |