Skip to content

Build wheels for macos with ceres-source #1974

Build wheels for macos with ceres-source

Build wheels for macos with ceres-source #1974

Workflow file for this run

name: Test
on: [push, pull_request, workflow_dispatch]
jobs:
py_build_deps:
outputs:
output: ${{ steps.extract_from_toml.outputs.output }}
runs-on: ubuntu-latest
defaults:
run:
working-directory: light-curve
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Extract build deps from pyproject.toml
id: extract_from_toml
run: |
echo "output="$(python -c 'import tomllib; print(" ".join(tomllib.load(open("pyproject.toml", "rb"))["build-system"]["requires"]))') >> "$GITHUB_OUTPUT"
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python_minor: ['7', '8', '9', '10', '11']
defaults:
run:
working-directory: light-curve
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Set up Python 3.${{ matrix.python_minor }}
uses: actions/setup-python@v5
with:
python-version: "3.${{ matrix.python_minor }}"
- name: Install tox
run: pip install tox
- name: Run Python tests
run: tox -e py3${{ matrix.python_minor }}
cargo-fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: cargo fmt --manifest-path=light-curve/Cargo.toml -- --check
cargo-clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
with:
shared-key: "stable-${{ runner.os }}"
workspaces: "light-curve"
- run: cargo clippy --manifest-path=light-curve/Cargo.toml --all-targets -- -D warnings
build:
runs-on: ${{ matrix.os }}
needs: [py_build_deps]
strategy:
fail-fast: false
matrix:
os: ['macos-latest', 'ubuntu-latest']
abi3: [true, false]
ceres: [false, 'source', 'system']
fftw: ['source', 'system', 'mkl']
gsl: [true, false]
exclude:
# We don't support MKL on macOS
- os: 'macos-latest'
fftw: 'mkl'
# Matrix is huge, let's make it more sparse
- ceres: 'system'
fftw: 'source'
- ceres: 'source'
fftw: 'system'
- ceres: 'source'
fftw: 'source'
gsl: false
- abi3: true
ceres: 'system'
- abi3: false
fftw: 'system'
- os: 'macos-latest'
ceres: 'system'
gsl: true
# We have very limited support for Windows, fftw-source is the only supported feature
include:
- os: 'windows-latest'
abi3: false
ceres: false
fftw: 'source'
gsl: false
- os: 'windows-latest'
abi3: true
ceres: false
fftw: 'source'
gsl: false
defaults:
run:
working-directory: light-curve
steps:
- uses: actions/checkout@v4
- name: Install ceres on macOS
if: ${{ matrix.ceres == 'system' && startsWith( matrix.os, 'macos' ) }}
run: brew install ceres-solver
- name: Install ceres on Linux
if: ${{ matrix.ceres == 'system' && startsWith( matrix.os, 'ubuntu' ) }}
run: |
sudo apt-get update
sudo apt-get install -y libunwind-dev
sudo apt-get install -y libceres-dev
- name: Install FFTW on macOS
if: ${{ matrix.fftw == 'system' && startsWith( matrix.os, 'macos' ) }}
run: brew install fftw
- name: Install FFTW on Linux
if: ${{ matrix.fftw == 'system' && startsWith( matrix.os, 'ubuntu' ) }}
run: |
sudo apt-get update
sudo apt-get install -y libfftw3-dev
- name: Install GSL on macOS
if: ${{ matrix.gsl && startsWith( matrix.os, 'macos' ) }}
run: brew install gsl
- name: Install GSL on Linux
if: ${{ matrix.gsl && startsWith( matrix.os, 'ubuntu' ) }}
run: |
sudo apt-get update
sudo apt-get install -y libgsl-dev
- name: Set up Python 3.7
if: ${{ ! matrix.abi3 }}
uses: actions/setup-python@v5
with:
python-version: '3.7'
- name: Set up Python 3.8
if: ${{ ! matrix.abi3 }}
uses: actions/setup-python@v5
with:
python-version: '3.8'
- name: Set up Python 3.9
if: ${{ ! matrix.abi3 }}
uses: actions/setup-python@v5
with:
python-version: '3.9'
- name: Set up Python 3.10
# No if here, we want to build abi3 wheels on 3.10
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Set up Python 3.11
if: ${{ ! matrix.abi3 }}
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Set up Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Install build deps
run: python3 -mpip install "${{ needs.py_build_deps.outputs.output }}"
- uses: Swatinem/rust-cache@v2
with:
shared-key: "stable-${{ runner.os }}"
workspaces: "light-curve"
- name: Build wheels for abi3=${{ matrix.abi3 }} fftw=${{ matrix.fftw }} ceres=${{ matrix.ceres }} gsl=${{ matrix.gsl }}
run: |
maturin build --find-interpreter --manylinux=off --locked --no-default-features --features=fftw-${{ matrix.fftw }}${{ matrix.ceres == 'source' && ',ceres-source' || '' }}${{ matrix.ceres == 'system' && ',ceres-system' || '' }}${{ matrix.gsl && ',gsl' || '' }}${{ matrix.abi3 && ',abi3' || '' }},mimalloc
- name: Install abi3audit
if: ${{ matrix.abi3 }}
run: python3 -mpip install abi3audit
- name: Check wheels for ABI compatibility on Linux
if: ${{ matrix.abi3 && startsWith( matrix.os, 'ubuntu' ) }}
run: abi3audit --strict target/wheels/*.whl
- name: Check wheels for ABI compatibility on Windows
if: ${{ matrix.abi3 && startsWith( matrix.os, 'windows' ) }}
run: Get-ChildItem -Path .\target\wheels -Filter *.whl | ForEach-Object { abi3audit --strict $_.FullName }
coverage:
runs-on: ubuntu-latest
needs: [py_build_deps]
defaults:
run:
working-directory: light-curve
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- uses: Swatinem/rust-cache@v2
with:
shared-key: "stable-${{ runner.os }}"
workspaces: "light-curve"
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install build deps
run: pip install "${{ needs.py_build_deps.outputs.output }}"
- name: Generate code coverage
run: |
source <(cargo llvm-cov show-env --export-prefix)
python -m venv venv
source venv/bin/activate
maturin develop --extras=test-no-bench,test
python -m pytest
cargo llvm-cov report --lcov --output-path lcov.info
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
files: lcov.info
fail_ci_if_error: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
benchmarks:
runs-on: ubuntu-latest
needs: [py_build_deps]
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install system packages
run: |
sudo apt-get update
sudo apt-get install -y libunwind-dev
sudo apt-get install -y libceres-dev libfftw3-dev libgsl-dev
- name: Run benchmarks
uses: CodSpeedHQ/action@v2
with:
token: ${{ secrets.CODSPEED_TOKEN }}
run: |
cd light-curve
python3 -m venv venv
. venv/bin/activate
pip install "${{ needs.py_build_deps.outputs.output }}" pytest-codspeed
maturin develop --extras=test-no-bench,test --release --no-default-features --features=ceres-system,fftw-system,gsl,mimalloc
python3 -mpytest -m "not (nobs or multi)" --codspeed tests/test_w_bench.py
msrv-build:
runs-on: ubuntu-latest
needs: [py_build_deps]
defaults:
run:
working-directory: light-curve
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.7
uses: actions/setup-python@v5
with:
python-version: '3.7'
- name: Set up Python 3.8
uses: actions/setup-python@v5
with:
python-version: '3.8'
- name: Set up Python 3.9
uses: actions/setup-python@v5
with:
python-version: '3.9'
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Get minimum supported Rust version
run: echo "::set-output name=msrv::$(grep '^rust-version = ' Cargo.toml | grep -o '[0-9.]\+')"
id: get_msrv
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ steps.get_msrv.outputs.msrv }}
- uses: Swatinem/rust-cache@v2
with:
shared-key: "msrv-${{ runner.os }}"
workspaces: "light-curve"
- name: Install build_deps
run: pip install "${{ needs.py_build_deps.outputs.output }}"
- name: Build
run: |
rustup default ${{ steps.get_msrv.outputs.msrv }}
maturin build --find-interpreter
arm:
runs-on: [self-hosted, linux, ARM64]
needs: [py_build_deps]
defaults:
run:
working-directory: light-curve
steps:
- uses: actions/checkout@v4
- name: Install build_deps
run: pip install "${{ needs.py_build_deps.outputs.output }}"
- name: Build
run: maturin build