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

Migrate to scikit-build-core #4352

Closed
wants to merge 84 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
2821925
migrate build system from `setuptools` to `scikit-build-core`
cringeyburger Aug 16, 2024
cab71d7
remove `setuptools` and `pybind11` from `nox` functions
cringeyburger Aug 16, 2024
ebd99b4
remove `install_sundials.sh`
cringeyburger Aug 16, 2024
4190eda
set default libs installation dir to `sundials_KLU_libs` in `install_…
cringeyburger Aug 16, 2024
98fa55a
ignore `SUNDIALS` and `SuiteSparse` libraries and distribution files
cringeyburger Aug 16, 2024
11a4176
reflect changes to support `scikit-build-core` and add support for cu…
cringeyburger Aug 16, 2024
02afa12
add path to `INSTALL_DIR` to find `SUNDIALS`
cringeyburger Aug 16, 2024
cf09058
add path to `INSTALL_DIR` and add config to find `openBLAS` and `SUIT…
cringeyburger Aug 16, 2024
4568f72
use the defined `python` in `dev` session
cringeyburger Aug 16, 2024
9d9d9c9
replace `setuptools` and `wheel` with `scikit-build-core` in workflows
cringeyburger Aug 16, 2024
31d5415
fix: doctests by updating expected `parameter_sets`
cringeyburger Aug 16, 2024
005bc00
set `RPATHS` to `casADi`, `SUNDIALS` and `SuiteSparse` to let the com…
cringeyburger Aug 16, 2024
e6347ad
feat: use `tomlkit` to parse through build-time requirements in `pypr…
cringeyburger Aug 17, 2024
828b897
set upper pins to build-time pre-requisites to avoid breaking changes
cringeyburger Aug 17, 2024
9d88596
feat: add `scikit-build-core` editable install support for Docker
cringeyburger Aug 17, 2024
ba1c5a5
fix: install `tomlkit` along with `nox` to fix dependency issues
cringeyburger Aug 17, 2024
a9cd92d
feat: use `scikit-build-core` in benchmarks
cringeyburger Aug 17, 2024
0e035ff
fix: hard code `INSTALL_DIR` to help CMake find libs in benchmarks
cringeyburger Aug 17, 2024
5f94160
fix: `test_on_push.yml` - add `BUILD_IDAKLU=ON` in notebooks builds
cringeyburger Aug 17, 2024
79eea01
fix: `run_periodic_tests.yml` - add `BUILD_IDAKLU=ON` in notebook builds
cringeyburger Aug 17, 2024
2c14cbe
update CI builds workflow with `scikit-build-core`
cringeyburger Aug 16, 2024
547fb5e
fix: exclude macOS systems from the custom `BLAS` finding sequence
cringeyburger Aug 18, 2024
f8e8d92
update `periodic_benchmarks.yml` with `scikit-build-core`
cringeyburger Aug 18, 2024
c74251d
fix: failing macOS builds
cringeyburger Aug 18, 2024
b5b3801
feat: inverse the logic - build `IDAKLU` by default and fallback to p…
cringeyburger Aug 18, 2024
9b17cb9
Merge branch 'develop' into migrate-to-sbc
cringeyburger Aug 19, 2024
2758cf9
feat: remove fallback option
cringeyburger Aug 19, 2024
7857edf
Merge branch 'develop' into migrate-to-sbc
cringeyburger Aug 20, 2024
670b30d
feat: add documentation for Windows source Installation and update ot…
cringeyburger Aug 20, 2024
7a28544
style: pre-commit fixes
pre-commit-ci[bot] Aug 20, 2024
8a0dd42
fix: style issues
cringeyburger Aug 20, 2024
1e685e9
fix: set unique names and clean Dockerfile
cringeyburger Aug 20, 2024
b862f9c
fix: pin `scipy` till upstream issues are fixed
cringeyburger Aug 21, 2024
5cdb904
improve docs
cringeyburger Aug 21, 2024
1f6bf65
fix: revert pin on `scipy`
cringeyburger Aug 21, 2024
5c4094e
Merge remote-tracking branch 'origin/develop' into migrate-to-sbc
cringeyburger Aug 23, 2024
7ec445b
feat: add new `.bat` script to set environment variables permanently
cringeyburger Aug 23, 2024
5265856
feat: remove upgrade pip commands from noxfile
cringeyburger Aug 23, 2024
9036388
feat: remove upper pins from all build-time dependencies, including `…
cringeyburger Aug 23, 2024
cc86402
feat: set the script for only `openBLAS`
cringeyburger Aug 23, 2024
13d0db8
feat: run macOS and Linux tests with IDAKLU and skip IREE tests using…
cringeyburger Aug 24, 2024
37ada42
feat: merge all install from source documentations and update `.gitig…
cringeyburger Aug 25, 2024
871d192
feat: add IREE support and fix unit tests
cringeyburger Aug 25, 2024
5aebe48
feat: clean `test_on_push` and fix `run_periodic_tests`
cringeyburger Aug 25, 2024
545bd8c
Merge branch 'develop' into migrate-to-sbc
cringeyburger Aug 26, 2024
f248b47
Merge branch 'develop' into migrate-to-sbc
cringeyburger Aug 26, 2024
377b4b7
feat: remove images and add `sundials_KLU_libs` in `.gitignore`, skip…
cringeyburger Aug 26, 2024
5581006
Merge branch 'develop' into migrate-to-sbc
cringeyburger Aug 26, 2024
89ec2b8
Merge branch 'develop' into migrate-to-sbc
cringeyburger Aug 26, 2024
5fba753
feat: enable IDAKLU in Windows tests
cringeyburger Aug 26, 2024
c561ebf
fix: install the solver in the project `src/pybamm/solvers` and not `…
cringeyburger Aug 27, 2024
94d4715
fix: set `CIBW_BUILD_FRONTEND` with no isolation
cringeyburger Aug 27, 2024
6d9cb3d
fix: add required `ninja` dependency
cringeyburger Aug 27, 2024
e164d68
fix: remove `CIBW_BUILD_FRONTEND` and add conditional in installation
cringeyburger Aug 27, 2024
3a7f253
Merge commit '8084c906adeefb95834c4e8eb43c9afb64d984b4' into migrate-…
cringeyburger Aug 27, 2024
b74921e
feat: resolve conversations
cringeyburger Aug 27, 2024
0d81822
Merge branch 'develop' into migrate-to-sbc
cringeyburger Aug 28, 2024
300317c
fix: resolve conversations
cringeyburger Aug 28, 2024
cccbf4a
test: find which tests need latex
cringeyburger Aug 28, 2024
c00eba3
fix: skip test if LaTeX is not found
cringeyburger Aug 28, 2024
b94947b
feat: add latex back in tests
cringeyburger Aug 28, 2024
20ed7c3
Merge branch 'develop' into migrate-to-sbc
cringeyburger Aug 28, 2024
5b42fe8
fix: security issues + skip check
cringeyburger Aug 29, 2024
36661b6
test: install openblas separately
cringeyburger Aug 29, 2024
29112f8
fix: style issues
cringeyburger Aug 29, 2024
d01562c
fix: CI tests by installing openBLAS separately
cringeyburger Aug 29, 2024
02e4f97
Merge branch 'develop' into migrate-to-sbc
cringeyburger Aug 30, 2024
92fbe27
Merge branch 'develop' into migrate-to-sbc
cringeyburger Sep 2, 2024
f2fa9f3
Merge branch 'develop' into migrate-to-sbc
cringeyburger Sep 2, 2024
ec5af1e
fix: remove redundant `env`
cringeyburger Sep 2, 2024
bbd6b3c
Merge branch 'develop' into migrate-to-sbc
cringeyburger Sep 4, 2024
d7e8af2
Merge branch 'develop' into migrate-to-sbc
cringeyburger Sep 7, 2024
912c28e
Merge branch 'develop' into migrate-to-sbc
cringeyburger Sep 8, 2024
4cfd995
Merge branch 'develop' into migrate-to-sbc
cringeyburger Sep 10, 2024
ef6a961
Merge branch 'develop' into migrate-to-sbc
cringeyburger Sep 13, 2024
97660cc
style: pre-commit fixes
pre-commit-ci[bot] Sep 13, 2024
f22ff4c
Merge branch 'develop' into migrate-to-sbc
cringeyburger Sep 21, 2024
a6afd17
Merge branch 'develop' into migrate-to-sbc
cringeyburger Sep 24, 2024
f60e621
Merge branch 'develop' into migrate-to-sbc
cringeyburger Sep 26, 2024
150f11f
Merge branch 'develop' into migrate-to-sbc
cringeyburger Sep 30, 2024
460143b
style: pre-commit fixes
pre-commit-ci[bot] Sep 30, 2024
73c81cf
fix: clean up config
cringeyburger Sep 30, 2024
a51b095
Merge branch 'develop' into migrate-to-sbc
cringeyburger Oct 15, 2024
0fbc7ed
fix: MacOS builds
cringeyburger Oct 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
2 changes: 1 addition & 1 deletion .github/workflows/benchmark_on_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:

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

- name: Install SuiteSparse and SUNDIALS
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 @@ -36,7 +36,7 @@ jobs:

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

- name: Install SuiteSparse and SUNDIALS
Expand All @@ -46,9 +46,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
41 changes: 23 additions & 18 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 # skip CasADi and CMake
# Fix access violation because GHA runners have modified PATH that picks wrong
# msvcp140.dll, see https://github.com/adang1345/delvewheel/issues/54
CIBW_REPAIR_WHEEL_COMMAND: delvewheel repair --add-path C:/Windows/System32 -w {dest_dir} {wheel}
Expand All @@ -110,17 +112,19 @@ 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_BEFORE_BUILD_LINUX: |
set -e -x
yum update -y
yum -y install openblas-devel
python scripts/install_KLU_Sundials.py
python -m pip install cmake casadi scikit-build-core pybind11
CIBW_REPAIR_WHEEL_COMMAND_LINUX: auditwheel repair -w {dest_dir} {wheel}
CIBW_TEST_EXTRAS: "all,dev,jax"
CIBW_TEST_COMMAND: |
Expand Down Expand Up @@ -148,9 +152,6 @@ 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: Install cibuildwheel
run: python -m pip install cibuildwheel

Expand Down Expand Up @@ -241,11 +242,12 @@ jobs:

python scripts/install_KLU_Sundials.py
python -m cibuildwheel --output-dir wheelhouse

env:
# 10.13 for Intel (macos-12/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 setuptools wheel delocate
CIBW_BEFORE_BUILD: python -m pip install cmake casadi scikit-build-core delocate
CIBW_REPAIR_WHEEL_COMMAND: |
if [[ $(uname -m) == "x86_64" ]]; then
delocate-listdeps {wheel} && delocate-wheel -v -w {dest_dir} {wheel}
Expand Down Expand Up @@ -289,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'
agriyakhetarpal marked this conversation as resolved.
Show resolved Hide resolved
name: Upload package to PyPI
needs: [
build_manylinux_wheels,
Expand Down
129 changes: 99 additions & 30 deletions .github/workflows/run_periodic_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,66 @@ concurrency:
cancel-in-progress: true

jobs:
run_tests:
runs-on: ${{ matrix.os }}
run_windows_unit_integration_tests:
env:
PYBAMM_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"
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, macos-12, macos-14, windows-latest ]
python-version: [ "3.9", "3.10", "3.11", "3.12" ]
name: Tests (${{ matrix.os }} / Python ${{ matrix.python-version }})
python-version: ["3.9", "3.10", "3.11", "3.12"]
name: Tests (windows-latest / Python ${{ matrix.python-version }})

steps:
- name: Check out PyBaMM repository
uses: actions/checkout@v4

- name: Install Linux system dependencies
if: matrix.os == 'ubuntu-latest'
- name: Install Windows system dependencies
run: choco install graphviz --version=8.0.5

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install vcpkg on Windows
run: |
sudo apt-get update
sudo apt-get install gfortran gcc graphviz pandoc libopenblas-dev texlive-latex-extra dvipng
cd C:\
rm -r -fo 'C:\vcpkg'
git clone https://github.com/microsoft/vcpkg
cd vcpkg
.\bootstrap-vcpkg.bat

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

- name: Run unit tests for windows-latest with Python ${{ matrix.python-version }}
run: python -m nox -s unit

- name: Run integration tests for windows-latest with Python ${{ matrix.python-version }}
run: python -m nox -s integration

run_macos_unit_integration_tests:
runs-on: ${{ matrix.os }}
env:
PYBAMM_IDAKLU_EXPR_CASADI: ON
PYBAMM_IDAKLU_EXPR_IREE: ON
strategy:
fail-fast: false
matrix:
os: [macos-12, macos-14]
python-version: ["3.9", "3.10", "3.11", "3.12"]
name: Tests (${{ matrix.os }} / Python ${{ matrix.python-version }})

steps:
- name: Check out PyBaMM repository
uses: actions/checkout@v4

- name: Install macOS system dependencies
if: matrix.os == 'macos-12' || matrix.os == 'macos-14'
env:
HOMEBREW_NO_INSTALL_CLEANUP: 1
HOMEBREW_NO_AUTO_UPDATE: 1
Expand All @@ -59,9 +98,38 @@ jobs:
brew install graphviz libomp
brew reinstall gcc

- name: Install Windows system dependencies
if: matrix.os == 'windows-latest'
run: choco install graphviz --version=8.0.5
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

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

- name: Install SuiteSparse and SUNDIALS on macOS
timeout-minutes: 10
run: python -m nox -s pybamm-requires

- name: Run unit tests for ${{ matrix.os }} with Python ${{ matrix.python-version }}
run: python -m nox -s unit

- name: Run integration tests for ${{ matrix.os }} with Python ${{ matrix.python-version }}
run: python -m nox -s integration

run_linux_unit_integration_coverage_tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
name: Tests (ubuntu-latest / Python ${{ matrix.python-version }})

steps:
- name: Check out PyBaMM repository
uses: actions/checkout@v4

- name: Install Linux system dependencies
run: sudo apt install gfortran gcc graphviz pandoc libopenblas-dev texlive-latex-extra dvipng

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
Expand All @@ -74,31 +142,34 @@ jobs:
- name: Install nox
run: python -m uv pip install nox[uv]

- name: Install SuiteSparse and SUNDIALS on GNU/Linux and macOS
- name: Install SuiteSparse and SUNDIALS on GNU/Linux
timeout-minutes: 10
if: matrix.os != 'windows-latest'
run: python -m nox -s pybamm-requires

- name: Run unit tests for ${{ matrix.os }} with Python ${{ matrix.python-version }}
if: matrix.os != 'ubuntu-latest' || matrix.python-version != '3.12'
- name: Run unit tests for GNU/Linux with Python ${{ matrix.python-version }}
if: matrix.python-version != '3.12'
run: python -m nox -s unit

- name: Run coverage tests for ${{ matrix.os }} with Python ${{ matrix.python-version }}
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.12'
- name: Run coverage tests for GNU/Linux with Python ${{ matrix.python-version }}
if: matrix.python-version == '3.12'
run: python -m nox -s coverage

- name: Upload coverage report
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.12'
if: matrix.python-version == '3.12'
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}

- name: Run integration tests for ${{ matrix.os }} with Python ${{ matrix.python-version }}
- name: Run integration tests for GNU/Linux with Python ${{ matrix.python-version }}
run: python -m nox -s integration

# Skips IDAKLU module compilation for speedups, which is already tested in other jobs.
run_doctests:
env:
BUILD_IDAKLU: OFF
runs-on: ubuntu-latest
strategy:
fail-fast: false
name: Doctests (ubuntu-latest / Python 3.11)

steps:
Expand All @@ -108,9 +179,7 @@ jobs:
fetch-depth: 0

- name: Install Linux system dependencies
run: |
sudo apt-get update
sudo apt-get install graphviz pandoc texlive-latex-extra dvipng
run: sudo apt install graphviz pandoc texlive-latex-extra dvipng

- name: Set up Python
uses: actions/setup-python@v5
Expand All @@ -131,16 +200,16 @@ jobs:

run_example_tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
name: Example notebooks (ubuntu-latest / Python 3.12)

steps:
- name: Check out PyBaMM repository
uses: actions/checkout@v4

- name: Install Linux system dependencies
run: |
sudo apt-get update
sudo apt-get install gfortran gcc graphviz pandoc libopenblas-dev texlive-latex-extra dvipng
run: sudo apt install gfortran gcc graphviz pandoc libopenblas-dev texlive-latex-extra dvipng

- name: Set up Python 3.12
uses: actions/setup-python@v5
Expand All @@ -162,16 +231,16 @@ jobs:

run_scripts_tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
name: Example scripts (ubuntu-latest / Python 3.12)

steps:
- name: Check out PyBaMM repository
uses: actions/checkout@v4

- name: Install Linux system dependencies
run: |
sudo apt-get update
sudo apt install gfortran gcc graphviz libopenblas-dev texlive-latex-extra dvipng
run: sudo apt install gfortran gcc graphviz libopenblas-dev texlive-latex-extra dvipng

- name: Set up Python 3.12
uses: actions/setup-python@v5
Expand Down
Loading
Loading