Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scikit-build-core CI Builds #4242

Closed
wants to merge 169 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
169 commits
Select commit Hold shift + click to select a range
8903591
Create migrate_package_test.yml
cringeyburger Jun 17, 2024
5f73b4f
Merge branch 'pybamm-team:develop' into migrate-test2
cringeyburger Jun 18, 2024
2bd2d53
renamed setup.py to old_setup.py
cringeyburger Jun 18, 2024
3a3e8ce
added pytest-cache in gitignore
cringeyburger Jun 18, 2024
7c97456
added .local paths to helo cmake find the libs
cringeyburger Jun 18, 2024
387ea77
added configs to build idaklu
cringeyburger Jun 18, 2024
62a6cf3
Merge branch 'pybamm-team:develop' into migrate-test2
cringeyburger Jun 18, 2024
82c1241
Added macOS wheel CI
cringeyburger Jun 18, 2024
5a775b0
commented linux CI wheel build
cringeyburger Jun 18, 2024
a3c107c
remove setuptools and wheel
cringeyburger Jun 18, 2024
9ecd25e
test all wheels
cringeyburger Jun 18, 2024
557b109
run just windows job
cringeyburger Jun 18, 2024
7822b85
disable tmate
cringeyburger Jun 18, 2024
265d58d
remove CMAKE_INSTALL_PREFIX from pyproject.toml
cringeyburger Jun 19, 2024
801747b
update noxfile
cringeyburger Jun 19, 2024
e86a948
Merge branch 'pybamm-team:develop' into develop
cringeyburger Jul 1, 2024
14c417f
Merge branch 'pybamm-team:develop' into develop
cringeyburger Jul 1, 2024
e5e4677
updates for windows builds
cringeyburger Jul 2, 2024
471574b
change order of installation and add checks
cringeyburger Jul 2, 2024
5e5a7ff
Merge branch 'develop' into migrate-test2
cringeyburger Jul 4, 2024
e33d428
Merge branch 'develop' into migrate-test2
cringeyburger Jul 6, 2024
adffb20
Merge branch 'pybamm-team:develop' into develop
cringeyburger Jul 6, 2024
55253a2
set new logic to find casadi
cringeyburger Jul 7, 2024
a0a94a4
remove errors and redundant code
cringeyburger Jul 7, 2024
82b7edd
added install target to CMakeLists.txt
cringeyburger Jul 7, 2024
3b96e28
style: pre-commit fixes
pre-commit-ci[bot] Jul 7, 2024
bed7975
enable all CI builds
cringeyburger Jul 7, 2024
d676363
add manual paths
cringeyburger Jul 7, 2024
3744002
remove redundant code
cringeyburger Jul 7, 2024
c6bf9b0
shift changes to `publish_pypi.yml`
cringeyburger Jul 7, 2024
5115921
remove `MANIFEST.in`
cringeyburger Jul 7, 2024
0df08f5
remove redundant code
cringeyburger Jul 7, 2024
c11d93d
improve logic
cringeyburger Jul 7, 2024
d1bdeac
check if openblas is required in vcpkg
cringeyburger Jul 7, 2024
9ccec88
reset old logic
cringeyburger Jul 7, 2024
1e98743
add custom dir for sundials and suitesparse libs
cringeyburger Jul 7, 2024
b1d4740
add conditionals for custom dir
cringeyburger Jul 7, 2024
59f314f
remove redundant code
cringeyburger Jul 7, 2024
12086b3
style: pre-commit fixes
pre-commit-ci[bot] Jul 7, 2024
25caf95
change installation location in script
cringeyburger Jul 7, 2024
ab9610c
modify cmakelists.txt to reflect new custom lib folder
cringeyburger Jul 8, 2024
c3612f7
change env variables
cringeyburger Jul 8, 2024
cf43115
fix cibuildwheel's library paths
cringeyburger Jul 8, 2024
f0d8791
debug paths
cringeyburger Jul 8, 2024
cbd9a9b
debug repair paths
cringeyburger Jul 8, 2024
00c6119
debug paths
cringeyburger Jul 8, 2024
46d6c09
debug CI paths
cringeyburger Jul 8, 2024
17d7bcb
edit paths
cringeyburger Jul 8, 2024
4bdf45f
change installation dir name to `sundials_KLU_libs`
cringeyburger Jul 8, 2024
14d151f
update paths
cringeyburger Jul 8, 2024
241a9b7
update paths
cringeyburger Jul 8, 2024
86a0aa6
update commands
cringeyburger Jul 8, 2024
1af3fa2
check if LD_LIBRARY_PATH is updated
cringeyburger Jul 9, 2024
e380e7a
upate lib paths for macos builds
cringeyburger Jul 9, 2024
28a8866
update macos paths
cringeyburger Jul 9, 2024
a49f67d
revert macos paths and debug linux builds
cringeyburger Jul 9, 2024
f087fd8
change linnux lib paths
cringeyburger Jul 9, 2024
eb1b6f9
try other path
cringeyburger Jul 10, 2024
4f53cf2
revert the paths
cringeyburger Jul 10, 2024
0ea2fbc
update the path during repairing
cringeyburger Jul 10, 2024
ffd0579
try string lateral of path
cringeyburger Jul 10, 2024
0ce3804
update path
cringeyburger Jul 10, 2024
0b29569
try hardcoding the path
cringeyburger Jul 10, 2024
ab723ad
update macos paths
cringeyburger Jul 11, 2024
d2f234c
remove DYLD paths
cringeyburger Jul 11, 2024
fd9b79a
Merge branch 'pybamm-team:develop' into develop
cringeyburger Jul 13, 2024
614b997
Merge branch 'pybamm-team:develop' into migrate-test2
cringeyburger Jul 13, 2024
c40735b
install pybind11 through pyproject table
cringeyburger Jul 13, 2024
ad283b0
fix path bug in workflow
cringeyburger Jul 14, 2024
1cb493c
add global to set pybind11 in default locations
cringeyburger Jul 14, 2024
67a4840
remove CONFIG
cringeyburger Jul 14, 2024
d655bdb
add Findpybind11.cmake
cringeyburger Jul 18, 2024
ead4c25
revert back to adding pybind11 to initially fix the CI builds
cringeyburger Jul 18, 2024
413af80
add path in linux before all
cringeyburger Jul 18, 2024
29ecd3f
set pybind11 global and find package
cringeyburger Jul 18, 2024
0c9d669
added pybind[global] in cibw linux and macos
cringeyburger Jul 18, 2024
4999062
typo: pybind to pybind11
cringeyburger Jul 18, 2024
d5cfc03
Merge branch 'pybamm-team:develop' into develop
cringeyburger Jul 20, 2024
45050a6
Merge remote-tracking branch 'origin/develop' into migrate-test2
cringeyburger Jul 20, 2024
4c07ce0
style: pre-commit fixes
pre-commit-ci[bot] Jul 20, 2024
d26d9d9
remove Findpybind11.cmake
cringeyburger Jul 20, 2024
efde7e3
add pybind11 in vcpkg
cringeyburger Jul 20, 2024
7c0af89
commented python development module in CMakeLists.txt
cringeyburger Jul 20, 2024
f9b6c19
add python interpretor development
cringeyburger Jul 20, 2024
3d55a8b
adding development module
cringeyburger Jul 20, 2024
577d479
resolve discussions
cringeyburger Jul 22, 2024
7c91efd
check is just `pybind11` works
cringeyburger Jul 22, 2024
70031ab
set all repair commands to exit with code 0
cringeyburger Jul 22, 2024
b7239db
Merge branch 'develop' into migrate-test2
cringeyburger Jul 23, 2024
3aa8a44
replace exit 0 with empty strings and update test command
cringeyburger Jul 23, 2024
198ce70
Merge branch 'pybamm-team:develop' into develop
cringeyburger Jul 23, 2024
54fa732
copying libs to wheelhouse for local testing
cringeyburger Jul 25, 2024
8d58e5b
Merge branch 'develop' into migrate-test2
cringeyburger Jul 25, 2024
3abcdd3
upload all artifacts including dylibs
cringeyburger Jul 25, 2024
d0fd2e4
Use `cibuildwheel` with `pipx`, use `CIBW_BEFORE_ALL`
agriyakhetarpal Jul 25, 2024
3016a97
Trigger wheel builds on PR events
agriyakhetarpal Jul 25, 2024
38731b2
Export `LD_LIBRARY_PATH` before wheel repair
agriyakhetarpal Jul 25, 2024
7da4a77
Remove `lib/` from SuiteSparse install path
agriyakhetarpal Jul 25, 2024
1f56d4b
Fix Windows wheel repair and test commands
agriyakhetarpal Jul 25, 2024
6c23284
Restore Linux wheel repair command
agriyakhetarpal Jul 25, 2024
e3f7917
Remove pybind11 git-clones
agriyakhetarpal Jul 25, 2024
b85c7fa
Copy libs to `/sundials_KLU_libs/lib/`
agriyakhetarpal Jul 25, 2024
74f530d
Some more fixes for rpaths
agriyakhetarpal Jul 25, 2024
8e5956a
Use cibuildwheel GitHub Action
agriyakhetarpal Jul 25, 2024
c2db80a
Fix Linux wheel repair
agriyakhetarpal Jul 25, 2024
2a285c9
Another try: fix Linux wheel repair
agriyakhetarpal Jul 25, 2024
bca4269
Debug placeholder setup
agriyakhetarpal Jul 25, 2024
7c77541
Use a one-liner wheel repair command
agriyakhetarpal Jul 25, 2024
f45b682
Update `yum` before running installation commands
agriyakhetarpal Jul 25, 2024
8c9736e
Replace `{project}` placeholder with $PWD
agriyakhetarpal Jul 25, 2024
876b4b1
Make PyPI publishing job harder to trigger
agriyakhetarpal Jul 25, 2024
bf7fb62
add optional builds using `BUILD_IDAKLU` env variable
cringeyburger Jul 31, 2024
4b08258
Merge branch 'develop' into migrate-test2
cringeyburger Jul 31, 2024
8f9c0a1
style: pre-commit fixes
pre-commit-ci[bot] Jul 31, 2024
4c9c207
Merge branch 'develop' into migrate-test2
cringeyburger Jul 31, 2024
d25265d
updated `Infrastructure` in `CONTRIBUTING.md`
cringeyburger Jul 31, 2024
6b12e2c
change lib path from `~/.local` to `PyBaMM/sundials_KLU_libs`
cringeyburger Jul 31, 2024
b248827
remove `setuptools` and `wheel` from dockerfile
cringeyburger Jul 31, 2024
d8fc46b
export `BUILD_IDAKLU=OFF` in `.readthedocs.yaml`
cringeyburger Jul 31, 2024
b52a5af
Merge branch 'develop' into migrate-test2
cringeyburger Jul 31, 2024
ce64d8b
use overrides in `pyproject.toml` to configure builds
cringeyburger Aug 1, 2024
5d8fcad
Merge branch 'pybamm-team:develop' into develop
cringeyburger Aug 1, 2024
b4bfe3b
Merge branch 'pybamm-team:develop' into migrate-test2
cringeyburger Aug 1, 2024
5c19841
TEST: Check overrides conditionals
cringeyburger Aug 1, 2024
5ce1897
TEST: testing another way for platform specific disable of `wheel.cmake`
cringeyburger Aug 1, 2024
0ff1f1a
remove extra overrides
cringeyburger Aug 1, 2024
31e029a
remove whitespace trails
cringeyburger Aug 1, 2024
6dc8ccb
Merge branch 'develop' into migrate-test2
cringeyburger Aug 2, 2024
8b97206
Merge branch 'pybamm-team:develop' into develop
cringeyburger Aug 5, 2024
bc12ec1
Merge branch 'pybamm-team:develop' into migrate-test2
cringeyburger Aug 5, 2024
2b8c179
Merge branch 'develop' into migrate-test2
cringeyburger Aug 6, 2024
4112cc1
resolve conflicts
cringeyburger Aug 6, 2024
0cab9aa
style: pre-commit fixes
pre-commit-ci[bot] Aug 6, 2024
78104f9
TEST: check why builds are failing
cringeyburger Aug 6, 2024
9bec3b3
set new cmake policy
cringeyburger Aug 6, 2024
617b5a2
fix: add `include` to `LD_LIBRARY_PATH`
cringeyburger Aug 6, 2024
46aacad
fix: see if the files are copied properly
cringeyburger Aug 6, 2024
e681e22
fix: set delocate to -vv
cringeyburger Aug 6, 2024
47e7447
fix: give direct path to library
cringeyburger Aug 6, 2024
afa78da
fix: try exporting PATH
cringeyburger Aug 6, 2024
0219515
fix: CI Builds by reverting renaming of `SUITESPARSE`
cringeyburger Aug 7, 2024
7001718
Merge branch 'develop' into migrate-test2
cringeyburger Aug 7, 2024
8073e3f
update build command in `asv.conf.json`
cringeyburger Aug 7, 2024
5bbd28c
add `workflow_dispatch` trigger for `benchmark_on_push.yml`
cringeyburger Aug 7, 2024
055ace0
add `workflow_dispatch` to `benchmark_on_push.yml`
cringeyburger Aug 7, 2024
d17bed7
export `BUILD_IDAKLU=ON` to enable `IDAKLU` installation
cringeyburger Aug 7, 2024
d0ebeac
fix: set `BUILD_IDAKLU=ON` in the correct place in `asv.conf.json`
cringeyburger Aug 7, 2024
c653e69
edit build command
cringeyburger Aug 7, 2024
61bcbbf
Merge branch 'develop' into migrate-test2
cringeyburger Aug 7, 2024
c596073
update dockerfile with new build system
cringeyburger Aug 7, 2024
6b634a2
style: pre-commit fixes
pre-commit-ci[bot] Aug 7, 2024
7e9a124
change the packeage name
cringeyburger Aug 7, 2024
8971982
typo: set upgrade
cringeyburger Aug 7, 2024
84f08d5
update `asv.conf.json` with new dependencies
cringeyburger Aug 7, 2024
2fc1911
Merge branch 'pybamm-team:develop' into develop
cringeyburger Aug 8, 2024
c619cf7
test: update build command
cringeyburger Aug 8, 2024
61328b0
fix: add pandas to python prerequisites
cringeyburger Aug 8, 2024
e37a59e
try to install the package to install all required dependencies
cringeyburger Aug 8, 2024
74f351d
remove installation commands
cringeyburger Aug 8, 2024
6439c89
test: modify docker workflow to run on GitHub actions
cringeyburger Aug 8, 2024
ed7cc9b
Merge branch 'pybamm-team:develop' into develop
cringeyburger Aug 8, 2024
e67a696
Merge branch 'develop' into migrate-test2
cringeyburger Aug 8, 2024
166cb7a
Merge branch 'develop' into migrate-test2
cringeyburger Aug 8, 2024
4abeeb2
Merge branch 'develop' into migrate-test2
cringeyburger Aug 10, 2024
d353af1
remove `setup.py`
cringeyburger Aug 10, 2024
6015fd2
Merge branch 'pybamm-team:develop' into migrate-test2
cringeyburger Aug 12, 2024
009eff5
Merge branch 'develop' into migrate-test2
cringeyburger Aug 13, 2024
6302c33
Merge branch 'develop' into migrate-test2
cringeyburger Aug 13, 2024
fd5ce58
debug: follow capital variable naming convention in `FindSUITESPARSE.…
cringeyburger Aug 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions .github/workflows/benchmark_on_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: Run benchmarks on push
on:
push:
branches: [main, develop]
workflow_dispatch:

concurrency:
# Cancel intermediate builds always
Expand All @@ -21,15 +22,20 @@ jobs:
- name: Install Linux system dependencies
run: |
sudo apt-get update
sudo apt install gfortran gcc libopenblas-dev
sudo apt install gfortran gcc libopenblas-dev liblapack-dev

- name: Install python dependencies
run: |
python -m pip install --upgrade pip wheel setuptools wget cmake casadi numpy
python -m pip install --upgrade pip scikit-build-core wget cmake casadi numpy
python -m pip install asv[virtualenv]

- name: Install SuiteSparse and SUNDIALS
run: python scripts/install_KLU_Sundials.py
run: |
python scripts/install_KLU_Sundials.py
mkdir -p $(pwd)/sundials_KLU_libs/lib64/
export LD_LIBRARY_PATH=$(pwd)/sundials_KLU_libs/lib64/:$LD_LIBRARY_PATH
export PATH=$(pwd)/sundials_KLU_libs/lib64/:$PATH
echo "LD_LIBRARY_PATH: $LD_LIBRARY_PATH"

- name: Fetch base branch
run: |
Expand All @@ -46,6 +52,7 @@ jobs:

- name: Run benchmarks
run: |
export BUILD_IDAKLU=ON
asv machine --machine "GitHubRunner"
# Get IDs of branch and PR commits
BASE_COMMIT=$(git rev-parse develop)
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
jobs:
build_docker_image:
# This workflow is only of value to PyBaMM and would always be skipped in forks
if: github.repository_owner == 'pybamm-team'
# if: github.repository_owner == 'pybamm-team'
name: Build image
runs-on: ubuntu-latest

Expand All @@ -23,19 +23,19 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# - name: Login to Docker Hub
# uses: docker/login-action@v3
# with:
# username: ${{ secrets.DOCKERHUB_USERNAME }}
# password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push Docker image to Docker Hub
uses: docker/build-push-action@v6
with:
context: .
file: scripts/Dockerfile
tags: pybamm/pybamm:latest
push: true
push: false
platforms: linux/amd64, linux/arm64

- name: List built image(s)
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/periodic_benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:

- name: Install python dependencies
run: |
python -m pip install --upgrade pip wheel setuptools wget cmake casadi numpy
python -m pip install --upgrade pip scikit-build-core wget cmake casadi numpy
python -m pip install asv[virtualenv]

- name: Install SuiteSparse and SUNDIALS
Expand All @@ -43,9 +43,6 @@ jobs:
run: |
asv machine --machine "GitHubRunner"
asv run --machine "GitHubRunner" NEW --show-stderr -v
env:
SUNDIALS_INST: $HOME/.local
LD_LIBRARY_PATH: $HOME/.local/lib

- name: Upload results as artifact
uses: actions/[email protected]
Expand Down
96 changes: 54 additions & 42 deletions .github/workflows/publish_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ on:
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
required: false
default: false
pull_request: # Temporarily trigger on PRs for debugging, remove later
types: [opened, synchronize, reopened]

# Set options available for all jobs that use cibuildwheel
env:
Expand Down Expand Up @@ -47,9 +49,6 @@ jobs:
with open(output_file, "a", encoding="utf-8") as output_stream:
output_stream.write(f"count={num_cpus}\n")

- name: Clone pybind11 repo (no history)
run: git clone --depth 1 --branch v2.12.0 https://github.com/pybind/pybind11.git -c advice.detachedHead=false

- name: Install vcpkg on Windows
run: |
cd C:\
Expand All @@ -72,7 +71,10 @@ jobs:
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}

- name: Build 64-bit wheels on Windows
run: pipx run cibuildwheel --output-dir wheelhouse
uses: pypa/[email protected]
with:
package-dir: .
output-dir: wheelhouse
env:
CIBW_ENVIRONMENT: >
PYBAMM_USE_VCPKG=ON
Expand All @@ -83,7 +85,7 @@ jobs:
CMAKE_GENERATOR_PLATFORM=x64
CMAKE_BUILD_PARALLEL_LEVEL=${{ steps.get_num_cores.outputs.count }}
CIBW_ARCHS: AMD64
CIBW_BEFORE_BUILD: python -m pip install setuptools wheel delvewheel # skip CasADi and CMake
CIBW_BEFORE_BUILD: python -m pip install scikit-build-core delvewheel pybind11
CIBW_REPAIR_WHEEL_COMMAND: delvewheel repair -w {dest_dir} {wheel}
CIBW_TEST_COMMAND: python -c "import pybamm; print(pybamm.IDAKLUSolver())"

Expand All @@ -106,18 +108,27 @@ jobs:
with:
python-version: 3.11

- name: Clone pybind11 repo (no history)
run: git clone --depth 1 --branch v2.12.0 https://github.com/pybind/pybind11.git -c advice.detachedHead=false

- name: Build wheels on Linux
run: pipx run cibuildwheel --output-dir wheelhouse
uses: pypa/[email protected]
with:
package-dir: .
output-dir: wheelhouse
env:
CIBW_ARCHS_LINUX: x86_64
CIBW_BEFORE_ALL_LINUX: >
yum -y install openblas-devel lapack-devel &&
bash scripts/install_sundials.sh 6.0.3 6.5.0
CIBW_BEFORE_BUILD_LINUX: python -m pip install cmake casadi setuptools wheel
CIBW_REPAIR_WHEEL_COMMAND_LINUX: auditwheel repair -w {dest_dir} {wheel}
CIBW_BEFORE_BUILD_LINUX: |
set -e -x

yum update -y
yum -y install openblas-devel lapack-devel
python scripts/install_KLU_Sundials.py
mkdir -p $(pwd)/sundials_KLU_libs/lib64/
export LD_LIBRARY_PATH=$(pwd)/sundials_KLU_libs/lib64/:$LD_LIBRARY_PATH
export PATH=$(pwd)/sundials_KLU_libs/lib64/:$PATH
echo "LD_LIBRARY_PATH: $LD_LIBRARY_PATH"

python -m pip install cmake casadi scikit-build-core pybind11
CIBW_REPAIR_WHEEL_COMMAND_LINUX: |
LD_LIBRARY_PATH=$(pwd)/sundials_KLU_libs/lib64/:$LD_LIBRARY_PATH auditwheel repair -w {dest_dir} {wheel}
CIBW_TEST_COMMAND: |
set -e -x
python -c "import pybamm; print(pybamm.IDAKLUSolver())"
Expand All @@ -142,18 +153,16 @@ jobs:
with:
python-version: '3.11'

- name: Clone pybind11 repo (no history)
run: git clone --depth 1 --branch v2.12.0 https://github.com/pybind/pybind11.git -c advice.detachedHead=false

- name: Set macOS-specific environment variables
run: echo "MACOSX_DEPLOYMENT_TARGET=11.0" >> $GITHUB_ENV

- name: Install cibuildwheel
run: python -m pip install cibuildwheel

- name: Build wheels on macOS
shell: bash
run: |
uses: pypa/[email protected]
with:
package-dir: .
output-dir: wheelhouse
env:
CIBW_BEFORE_ALL: |
set -e -x

# Set LLVM-OpenMP URL
Expand Down Expand Up @@ -190,23 +199,25 @@ jobs:
export PATH=$(pwd)/gfortran_installed/gfortran-darwin-arm64-native/bin:$PATH
fi

# link libgfortran dylibs and place them in $HOME/.local/lib
# and then change rpath to $HOME/.local/lib for each of them
# link libgfortran dylibs and place them in sundials_KLU_libs/lib/
# and then change rpath to /sundials_KLU_libs/lib/ for each of them
# Note: libgcc_s.1.dylib not available on macOS arm64; skip for now
mkdir -p $HOME/.local/lib

mkdir -p $(pwd)/sundials_KLU_libs/lib/

if [[ $(uname -m) == "x86_64" ]]; then
lib_dir=$(pwd)/gfortran_installed/gfortran-darwin-x86_64-native/lib
for lib in libgfortran.5.dylib libgfortran.dylib libquadmath.0.dylib libquadmath.dylib libgcc_s.1.dylib libgcc_s.1.1.dylib; do
cp $lib_dir/$lib $HOME/.local/lib/
install_name_tool -id $HOME/.local/lib/$lib $HOME/.local/lib/$lib
codesign --force --sign - $HOME/.local/lib/$lib
cp $lib_dir/$lib $(pwd)/sundials_KLU_libs/lib/
install_name_tool -id $(pwd)/sundials_KLU_libs/lib/$lib $(pwd)/sundials_KLU_libs/lib/$lib
codesign --force --sign - $(pwd)/sundials_KLU_libs/lib/$lib
done
elif [[ $(uname -m) == "arm64" ]]; then
lib_dir=$(pwd)/gfortran_installed/gfortran-darwin-arm64-native/lib
for lib in libgfortran.5.dylib libgfortran.dylib libquadmath.0.dylib libquadmath.dylib libgcc_s.1.1.dylib; do
cp $lib_dir/$lib $HOME/.local/lib/
install_name_tool -id $HOME/.local/lib/$lib $HOME/.local/lib/$lib
codesign --force --sign - $HOME/.local/lib/$lib
cp $lib_dir/$lib $(pwd)/sundials_KLU_libs/lib/
install_name_tool -id $(pwd)/sundials_KLU_libs/lib/$lib $(pwd)/sundials_KLU_libs/lib/$lib
codesign --force --sign - $(pwd)/sundials_KLU_libs/lib/$lib
done
fi

Expand All @@ -221,10 +232,10 @@ jobs:
PREFIX="/opt/homebrew/Caskroom/miniforge/base/envs/pybamm-dev"
fi

# Copy libomp.dylib from PREFIX to $HOME/.local/lib, needed for wheel repair
cp $PREFIX/lib/libomp.dylib $HOME/.local/lib/
install_name_tool -id $HOME/.local/lib/libomp.dylib $HOME/.local/lib/libomp.dylib
codesign --force --sign - $HOME/.local/lib/libomp.dylib
# Copy libomp.dylib from PREFIX to /sundials_KLU_libs/lib/, needed for wheel repair
cp $PREFIX/lib/libomp.dylib $(pwd)/sundials_KLU_libs/lib/
install_name_tool -id $(pwd)/sundials_KLU_libs/lib/libomp.dylib $(pwd)/sundials_KLU_libs/lib/libomp.dylib
codesign --force --sign - $(pwd)/sundials_KLU_libs/lib/libomp.dylib

export CC=/usr/bin/clang
export CXX=/usr/bin/clang++
Expand All @@ -233,15 +244,13 @@ jobs:
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 scripts/install_KLU_Sundials.py
python -m cibuildwheel --output-dir wheelhouse
env:
CIBW_ARCHS_MACOS: auto
CIBW_BEFORE_BUILD: python -m pip install cmake casadi setuptools wheel delocate
CIBW_BEFORE_BUILD: python -m pip install cmake casadi scikit-build-core delocate pybind11
CIBW_REPAIR_WHEEL_COMMAND: |
export LD_LIBRARY_PATH=$(pwd)/sundials_KLU_libs/lib/:$LD_LIBRARY_PATH
echo "$LD_LIBRARY_PATH"

if [[ $(uname -m) == "x86_64" ]]; then
delocate-listdeps {wheel} && delocate-wheel -v -w {dest_dir} {wheel}
elif [[ $(uname -m) == "arm64" ]]; then
Expand Down Expand Up @@ -282,7 +291,10 @@ jobs:

publish_pypi:
# This job is only of value to PyBaMM and would always be skipped in forks
if: github.event_name != 'schedule' && github.repository == 'pybamm-team/PyBaMM'
if: >-
(github.event_name == 'workflow_dispatch' ||
github.event_name == 'release') &&
github.repository == 'pybamm-team/PyBaMM'
name: Upload package to PyPI
needs: [
build_manylinux_wheels,
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update_version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:

- name: Install dependencies
run: |
pip install wheel
pip install scikit-build-core
pip install --editable ".[all]"

# update all the version strings and add CHANGELOG headings
Expand Down
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
*__pycache__/
*.cache
.ipynb_checkpoints/
.pytest_cache

# Sphinx build files
docs/_build/
Expand All @@ -55,8 +56,7 @@ matplotlibrc
ideas/
.idea/

# setup.py files
*.egg-info
# distribution files
dist/

# coverage
Expand Down Expand Up @@ -85,6 +85,7 @@ sundials-*
SuiteSparse-*
build_sundials
KLU_module_deps
sundials_KLU_libs/include

# downloads
*.gz
Expand Down
28 changes: 20 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ if(DEFINED ENV{VCPKG_DEFAULT_TRIPLET} AND NOT DEFINED VCPKG_TARGET_TRIPLET)
CACHE STRING "Vcpkg target triplet")
endif()

set(CUSTOM_INSTALL_DIR ${CMAKE_CURRENT_SOURCE_DIR}/sundials_KLU_libs)

project(idaklu)

set(CMAKE_CXX_STANDARD 14)
Expand All @@ -32,10 +34,12 @@ endif()
# casadi seems to compile without the newer versions of std::string
add_compile_definitions(_GLIBCXX_USE_CXX11_ABI=0)

# Add pybind11
if(NOT PYBIND11_DIR)
set(PYBIND11_DIR pybind11)
endif()
add_subdirectory(${PYBIND11_DIR})
find_package(Python REQUIRED COMPONENTS Interpreter Development.Module)
find_package(pybind11 CONFIG REQUIRED)

# Check Casadi build flag
if(NOT DEFINED PYBAMM_IDAKLU_EXPR_CASADI)
Expand Down Expand Up @@ -104,10 +108,11 @@ pybind11_add_module(idaklu
src/pybamm/solvers/c_solvers/idaklu/Expressions/Base/ExpressionTypes.hpp
# IDAKLU expressions - concrete implementations
${IDAKLU_EXPR_CASADI_SOURCE_FILES}
${IDAKLU_EXPR_IREE_SOURCE_FILES}
)
${IDAKLU_EXPR_IREE_SOURCE_FILES})

if (NOT DEFINED USE_PYTHON_CASADI)
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
set(USE_PYTHON_CASADI FALSE)
else()
set(USE_PYTHON_CASADI TRUE)
endif()

Expand Down Expand Up @@ -140,7 +145,10 @@ set_target_properties(
)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR})

# Sundials
set(SUNDIALS_ROOT ${CUSTOM_INSTALL_DIR})
message("SUNDIALS_ROOT: ${SUNDIALS_ROOT}")
find_package(SUNDIALS REQUIRED)
message("SUNDIALS found in ${SUNDIALS_INCLUDE_DIR}: ${SUNDIALS_LIBRARIES}")
target_include_directories(idaklu PRIVATE ${SUNDIALS_INCLUDE_DIR})
Expand All @@ -149,14 +157,16 @@ target_link_libraries(idaklu PRIVATE ${SUNDIALS_LIBRARIES} casadi)
# link suitesparse
# if using vcpkg, use config mode to
# find suitesparse. Otherwise, use FindSuiteSparse module
set(SUITESPARSE_ROOT ${CUSTOM_INSTALL_DIR})
message("SUITESPARSE_ROOT: ${SUITESPARSE_ROOT}")
if(DEFINED VCPKG_ROOT_DIR)
find_package(SuiteSparse CONFIG REQUIRED)
find_package(SUITESPARSE CONFIG REQUIRED)
cringeyburger marked this conversation as resolved.
Show resolved Hide resolved
else()
find_package(SuiteSparse REQUIRED)
find_package(SUITESPARSE REQUIRED)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
find_package(SUITESPARSE REQUIRED)
find_package(SuiteSparse REQUIRED)

message("SuiteSparse found in ${SuiteSparse_INCLUDE_DIRS}: ${SuiteSparse_LIBRARIES}")
endif()
include_directories(${SuiteSparse_INCLUDE_DIRS})
target_link_libraries(idaklu PRIVATE ${SuiteSparse_LIBRARIES})
include_directories(${SUITESPARSE_INCLUDE_DIRS})
target_link_libraries(idaklu PRIVATE ${SUITESPARSE_LIBRARIES})
Comment on lines +168 to +169
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
include_directories(${SUITESPARSE_INCLUDE_DIRS})
target_link_libraries(idaklu PRIVATE ${SUITESPARSE_LIBRARIES})
include_directories(${SuiteSparse_INCLUDE_DIRS})
target_link_libraries(idaklu PRIVATE ${SuiteSparse_LIBRARIES})


# IREE (MLIR compiler and runtime library) build settings
if(${PYBAMM_IDAKLU_EXPR_IREE} STREQUAL "ON" )
Expand All @@ -170,3 +180,5 @@ if(${PYBAMM_IDAKLU_EXPR_IREE} STREQUAL "ON" )
target_link_libraries(idaklu PRIVATE iree_compiler_bindings_c_loader)
target_link_libraries(idaklu PRIVATE iree_runtime_runtime)
endif()

install(TARGETS idaklu DESTINATION src/pybamm/solvers)
Loading
Loading