Bump SuiteSparse to v7.11.0, drop libgfortran
requirement for Linux/macOS builds
#245
Workflow file for this run
This file contains hidden or 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 wheels | |
on: | |
release: | |
types: [ published ] | |
workflow_dispatch: | |
pull_request: | |
branches: | |
- "main" | |
env: | |
CIBW_BUILD_VERBOSITY: 2 | |
CIBW_BUILD_FRONTEND: "pip; args: --no-build-isolation" | |
# Skip PyPy and MUSL builds in any and all jobs | |
CIBW_SKIP: "pp* *musllinux*" | |
FORCE_COLOR: 3 | |
jobs: | |
build_windows_wheels: | |
name: Wheels (Windows) | |
runs-on: windows-latest | |
steps: | |
- uses: actions/checkout@v5 | |
with: | |
submodules: 'true' | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: 3.12 | |
# Pin to 2024.12.16 to avoid issues with finding SuiteSparse in manifest mode | |
# after SuiteSparse was split into subpackages in recent vcpkg releases. | |
- name: Install vcpkg on Windows | |
run: | | |
cd C:\ | |
rm -r -fo 'C:\vcpkg' | |
git clone https://github.com/microsoft/vcpkg --branch 2024.12.16 | |
cd vcpkg | |
.\bootstrap-vcpkg.bat | |
- name: Build wheels on Windows | |
run: pipx run cibuildwheel --output-dir wheelhouse | |
env: | |
CIBW_ENVIRONMENT: > | |
PYBAMMSOLVERS_USE_VCPKG=ON | |
VCPKG_ROOT_DIR=C:\vcpkg | |
VCPKG_DEFAULT_TRIPLET=x64-windows-static-md | |
VCPKG_FEATURE_FLAGS=manifests,registries | |
CMAKE_GENERATOR="Visual Studio 17 2022" | |
CMAKE_GENERATOR_PLATFORM=x64 | |
CIBW_ARCHS: AMD64 | |
CIBW_BEFORE_BUILD: python -m pip install setuptools delvewheel # skip CasADi and CMake | |
CIBW_REPAIR_WHEEL_COMMAND: delvewheel repair --add-path C:/Windows/System32 -w {dest_dir} {wheel} | |
CIBW_TEST_EXTRAS: "dev" | |
CIBW_TEST_COMMAND: | | |
python -m pytest {project}/tests | |
- name: Upload Windows wheels | |
uses: actions/upload-artifact@v4 | |
with: | |
name: wheels_windows | |
path: ./wheelhouse/*.whl | |
if-no-files-found: error | |
build_manylinux_wheels: | |
name: Wheels (Linux) | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v5 | |
with: | |
submodules: 'true' | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: 3.12 | |
- name: Build wheels on Linux | |
run: pipx run cibuildwheel --output-dir wheelhouse | |
env: | |
CIBW_ARCHS_LINUX: x86_64 | |
CIBW_BEFORE_ALL_LINUX: > | |
yum -y install openblas-devel lapack-devel && | |
python install_KLU_Sundials.py | |
CIBW_BEFORE_BUILD_LINUX: python -m pip install cmake casadi==3.6.7 setuptools wheel | |
CIBW_REPAIR_WHEEL_COMMAND_LINUX: auditwheel repair -w {dest_dir} {wheel} | |
CIBW_TEST_EXTRAS: "dev" | |
CIBW_TEST_COMMAND: | | |
set -e -x | |
python -m pytest {project}/tests | |
- name: Upload wheels for Linux | |
uses: actions/upload-artifact@v4 | |
with: | |
name: wheels_manylinux | |
path: ./wheelhouse/*.whl | |
if-no-files-found: error | |
build_macos_wheels: | |
name: Wheels (${{ matrix.os }}) | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [macos-13, macos-14] | |
fail-fast: false | |
steps: | |
- uses: actions/checkout@v5 | |
with: | |
submodules: 'true' | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: 3.12 | |
- name: Install cibuildwheel | |
run: python -m pip install cibuildwheel | |
- name: Build wheels on macOS | |
shell: bash | |
run: | | |
set -e -x | |
# Set LLVM-OpenMP URL | |
if [[ $(uname -m) == "x86_64" ]]; then | |
OPENMP_URL="https://anaconda.org/conda-forge/llvm-openmp/11.1.0/download/osx-64/llvm-openmp-11.1.0-hda6cdc1_1.tar.bz2" | |
elif [[ $(uname -m) == "arm64" ]]; then | |
OPENMP_URL="https://anaconda.org/conda-forge/llvm-openmp/11.1.0/download/osx-arm64/llvm-openmp-11.1.0-hf3c4609_1.tar.bz2" | |
fi | |
export SDKROOT=${SDKROOT:-$(xcrun --show-sdk-path)} | |
SOLVER_LIB_PATH=$(pwd)/.idaklu/lib | |
# Can't download LLVM-OpenMP directly, use conda and set environment variables | |
brew install miniforge | |
conda create -n pybammsolvers-dev $OPENMP_URL | |
if [[ $(uname -m) == "x86_64" ]]; then | |
PREFIX="/usr/local/Caskroom/miniforge/base/envs/pybammsolvers-dev" | |
elif [[ $(uname -m) == "arm64" ]]; then | |
PREFIX="/opt/homebrew/Caskroom/miniforge/base/envs/pybammsolvers-dev" | |
fi | |
# Copy libomp.dylib from PREFIX to $SOLVER_LIB_PATH, needed for wheel repair | |
cp $PREFIX/lib/libomp.dylib $SOLVER_LIB_PATH/. | |
install_name_tool -id $SOLVER_LIB_PATH/libomp.dylib $SOLVER_LIB_PATH/libomp.dylib | |
codesign --force --sign - $SOLVER_LIB_PATH/libomp.dylib | |
export CC=/usr/bin/clang | |
export CXX=/usr/bin/clang++ | |
export CPPFLAGS="$CPPFLAGS -Xpreprocessor -fopenmp" | |
export CFLAGS="$CFLAGS -I$PREFIX/include" | |
export CXXFLAGS="$CXXFLAGS -I$PREFIX/include" | |
export LDFLAGS="$LDFLAGS -L$PREFIX/lib -lomp" | |
# cibuildwheel not recognising its environment variable, so set manually | |
export CIBUILDWHEEL="1" | |
python install_KLU_Sundials.py | |
python -m cibuildwheel --output-dir wheelhouse | |
env: | |
# 10.13 for Intel (macos-13), 11.0 for Apple Silicon (macos-14 and macos-latest) | |
MACOSX_DEPLOYMENT_TARGET: ${{ matrix.os == 'macos-14' && '11.0' || '10.13' }} | |
CIBW_ARCHS_MACOS: auto | |
CIBW_BEFORE_BUILD: python -m pip install cmake casadi==3.6.7 setuptools delocate | |
CIBW_REPAIR_WHEEL_COMMAND: | | |
if [[ $(uname -m) == "x86_64" ]]; then | |
delocate-listdeps {wheel} && delocate-wheel -v -w {dest_dir} {wheel} | |
elif [[ $(uname -m) == "arm64" ]]; then | |
# Use higher macOS target for now since casadi/libc++.1.0.dylib is still not fixed | |
delocate-listdeps {wheel} && delocate-wheel -v -w {dest_dir} {wheel} --require-target-macos-version 11.1 | |
for file in {dest_dir}/*.whl; do mv "$file" "${file//macosx_11_1/macosx_11_0}"; done | |
fi | |
CIBW_TEST_EXTRAS: "dev" | |
CIBW_TEST_COMMAND: | | |
set -e -x | |
python -m pytest {project}/tests | |
- name: Upload wheels for macOS (amd64, arm64) | |
uses: actions/upload-artifact@v4 | |
with: | |
name: wheels_${{ matrix.os }} | |
path: ./wheelhouse/*.whl | |
if-no-files-found: error | |
build_sdist: | |
name: Build SDist | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v5 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: 3.12 | |
- name: Build SDist | |
run: pipx run build --sdist | |
- name: Upload SDist | |
uses: actions/upload-artifact@v4.4.0 | |
with: | |
name: sdist | |
path: ./dist/*.tar.gz | |
if-no-files-found: error | |
publish_pypi: | |
if: ${{ github.event_name == 'release' && github.repository == 'pybamm-team/pybammsolvers' }} | |
name: Upload package to PyPI | |
needs: [ | |
build_manylinux_wheels, | |
build_macos_wheels, | |
build_windows_wheels, | |
build_sdist | |
] | |
runs-on: ubuntu-latest | |
environment: | |
name: pypi | |
url: https://pypi.org/p/pybammsolvers | |
permissions: | |
id-token: write | |
steps: | |
- name: Download all artifacts | |
uses: actions/download-artifact@v5 | |
with: | |
path: artifacts | |
merge-multiple: true | |
- name: Sanity check downloaded artifacts | |
run: ls -lA artifacts/ | |
- name: Publish to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
packages-dir: artifacts/ |