Skip to content

Commit 5000e57

Browse files
Merge branch 'main' into no-fortran
2 parents 47df3b7 + 7ee4fe5 commit 5000e57

File tree

10 files changed

+40
-39
lines changed

10 files changed

+40
-39
lines changed

.github/workflows/build_wheels.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
steps:
2222
- uses: actions/checkout@v5
2323
with:
24-
submodules: 'true'
24+
submodules: 'recursive'
2525
- uses: actions/setup-python@v5
2626
with:
2727
python-version: 3.12
@@ -47,7 +47,7 @@ jobs:
4747
CMAKE_GENERATOR="Visual Studio 17 2022"
4848
CMAKE_GENERATOR_PLATFORM=x64
4949
CIBW_ARCHS: AMD64
50-
CIBW_BEFORE_BUILD: python -m pip install setuptools delvewheel # skip CasADi and CMake
50+
CIBW_BEFORE_BUILD: python -m pip install setuptools delvewheel pybind11 # skip CasADi and CMake
5151
CIBW_REPAIR_WHEEL_COMMAND: delvewheel repair --add-path C:/Windows/System32 -w {dest_dir} {wheel}
5252
CIBW_TEST_EXTRAS: "dev"
5353
CIBW_TEST_COMMAND: |
@@ -65,7 +65,7 @@ jobs:
6565
steps:
6666
- uses: actions/checkout@v5
6767
with:
68-
submodules: 'true'
68+
submodules: 'recursive'
6969

7070
- uses: actions/setup-python@v5
7171
with:
@@ -78,7 +78,7 @@ jobs:
7878
CIBW_BEFORE_ALL_LINUX: >
7979
yum -y install openblas-devel lapack-devel &&
8080
python install_KLU_Sundials.py
81-
CIBW_BEFORE_BUILD_LINUX: python -m pip install cmake casadi==3.6.7 setuptools wheel
81+
CIBW_BEFORE_BUILD_LINUX: python -m pip install cmake casadi==3.6.7 setuptools wheel pybind11
8282
CIBW_REPAIR_WHEEL_COMMAND_LINUX: auditwheel repair -w {dest_dir} {wheel}
8383
CIBW_TEST_EXTRAS: "dev"
8484
CIBW_TEST_COMMAND: |
@@ -102,7 +102,7 @@ jobs:
102102
steps:
103103
- uses: actions/checkout@v5
104104
with:
105-
submodules: 'true'
105+
submodules: 'recursive'
106106
- uses: actions/setup-python@v5
107107
with:
108108
python-version: 3.12
@@ -168,7 +168,7 @@ jobs:
168168
# 10.13 for Intel (macos-13), 11.0 for Apple Silicon (macos-14 and macos-latest)
169169
MACOSX_DEPLOYMENT_TARGET: ${{ matrix.os == 'macos-14' && '11.0' || '10.13' }}
170170
CIBW_ARCHS_MACOS: auto
171-
CIBW_BEFORE_BUILD: python -m pip install cmake casadi==3.6.7 setuptools delocate
171+
CIBW_BEFORE_BUILD: python -m pip install cmake casadi==3.6.7 setuptools delocate pybind11
172172
CIBW_REPAIR_WHEEL_COMMAND: |
173173
if [[ $(uname -m) == "x86_64" ]]; then
174174
delocate-listdeps {wheel} && delocate-wheel -v -w {dest_dir} {wheel}

.github/workflows/integration_tests.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,9 @@ jobs:
2121
steps:
2222
- uses: actions/checkout@v5
2323
with:
24-
submodules: 'true'
24+
submodules: 'recursive'
2525

26-
- name: Set up Python ${{ matrix.python-version }}
27-
uses: actions/setup-python@v5
28-
with:
29-
python-version: ${{ matrix.python-version }}
30-
31-
- name: Install dependencies (MacOs)
26+
- name: Install dependencies (macOS)
3227
env:
3328
HOMEBREW_NO_INSTALL_CLEANUP: 1
3429
HOMEBREW_NO_AUTO_UPDATE: 1
@@ -39,20 +34,25 @@ jobs:
3934
brew install libomp
4035
brew reinstall gcc
4136
37+
- name: Set up Python ${{ matrix.python-version }}
38+
uses: actions/setup-python@v5
39+
with:
40+
python-version: ${{ matrix.python-version }}
41+
4242
- name: Build and test
4343
run: |
4444
cd ..
4545
git clone https://github.com/pybamm-team/PyBaMM.git
4646
# Install PyBaMM
4747
cd PyBaMM
4848
pip install -e ".[all,dev,jax]"
49-
49+
5050
# Replace PyBaMM solvers
5151
cd ../pybammsolvers
5252
pip uninstall pybammsolvers --yes
5353
python install_KLU_Sundials.py
5454
pip install .
55-
55+
5656
# Run pybamm tests
5757
cd ../PyBaMM
5858
pytest tests/unit

.github/workflows/pre-commit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ jobs:
1414
steps:
1515
- uses: actions/checkout@v5
1616
with:
17-
submodules: 'true'
17+
submodules: 'recursive'
1818
- uses: actions/setup-python@v5
1919
- uses: pre-commit/action@v3.0.1

.github/workflows/unit_tests.yml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,11 @@ jobs:
2121
steps:
2222
- uses: actions/checkout@v5
2323
with:
24-
submodules: 'true'
25-
26-
- name: Set up Python ${{ matrix.python-version }}
27-
uses: actions/setup-python@v5
28-
with:
29-
python-version: ${{ matrix.python-version }}
24+
submodules: 'recursive'
3025

3126
- name: Install dependencies (Linux)
3227
if: matrix.os == 'ubuntu-latest'
33-
run: |
34-
sudo apt-get install gcc gfortran libopenblas-dev
35-
pip install nox
28+
run: sudo apt-get install gcc gfortran libopenblas-dev
3629

3730
- name: Install dependencies (macOS)
3831
if: matrix.os == 'macos-13' || matrix.os == 'macos-latest'
@@ -45,6 +38,14 @@ jobs:
4538
brew analytics off
4639
brew install libomp
4740
brew reinstall gcc
41+
42+
- name: Set up Python ${{ matrix.python-version }}
43+
uses: actions/setup-python@v5
44+
with:
45+
python-version: ${{ matrix.python-version }}
46+
47+
- name: Install nox
48+
run: |
4849
pip install nox
4950
5051
- name: Build and test

.gitmodules

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
[submodule "pybind11"]
2-
path = pybind11
3-
url = https://github.com/pybind/pybind11.git
41
[submodule "sundials"]
52
path = sundials
63
url = git@github.com:LLNL/sundials.git

CMakeLists.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,7 @@ endif ()
3636
# casadi seems to compile without the newer versions of std::string
3737
add_compile_definitions(_GLIBCXX_USE_CXX11_ABI=0)
3838

39-
if (NOT PYBIND11_DIR)
40-
set(PYBIND11_DIR pybind11)
41-
endif ()
42-
add_subdirectory(${PYBIND11_DIR})
39+
find_package(pybind11 CONFIG REQUIRED)
4340

4441
# Check Casadi build flag
4542
if (NOT DEFINED PYBAMM_IDAKLU_EXPR_CASADI)

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Mac dependencies can be installed using brew
3232
```bash
3333
brew install libomp
3434
brew reinstall gcc
35-
git submodule update --init --recurisive
35+
git submodule update --init --recursive
3636
python install_KLU_Sundials.py
3737
pip install .
3838
```
@@ -43,8 +43,8 @@ Linux installs may vary based on the distribution, however, the basic build can
4343
be performed with the following commands:
4444
```bash
4545
sudo apt-get install libopenblas-dev gcc make g++ build-essential
46-
pip install cmake casadi setuptools wheel
47-
git submodules update --init --recurisive
46+
git submodules update --init --recursive
47+
pip install cmake casadi setuptools wheel "pybind11[global]"
4848
python install_KLU_Sundials.py
4949
pip install .
5050
```

pybind11

Lines changed: 0 additions & 1 deletion
This file was deleted.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ requires = [
77
# cross platforms, so updates to its minimum version here should be accompanied
88
# by a version bump in https://github.com/pybamm-team/casadi-vcpkg-registry.
99
"cmake; platform_system!='Windows'",
10+
"pybind11[global]>=3.0.1",
1011
]
1112
build-backend = "setuptools.build_meta"
1213

setup.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55
from pathlib import Path
66
from platform import system
77

8-
from setuptools import setup, Extension
8+
from setuptools import setup
99
from setuptools.command.install import install
10-
from setuptools.command.build_ext import build_ext
1110
from setuptools.command.bdist_wheel import bdist_wheel
1211

12+
import pybind11
13+
from pybind11.setup_helpers import Pybind11Extension, build_ext
1314

1415
default_lib_dir = (
1516
"" if system() == "Windows" else str(Path(__file__).parent.resolve() / ".idaklu")
@@ -92,11 +93,15 @@ def run(self):
9293

9394
build_type = os.getenv("PYBAMM_CPP_BUILD_TYPE", "Release")
9495
idaklu_expr_casadi = os.getenv("PYBAMM_IDAKLU_EXPR_CASADI", "ON")
96+
97+
pybind11_cmake_dir = pybind11.get_cmake_dir()
98+
9599
cmake_args = [
96100
f"-DCMAKE_BUILD_TYPE={build_type}",
97101
f"-DPYTHON_EXECUTABLE={sys.executable}",
98102
"-DUSE_PYTHON_CASADI={}".format("TRUE" if use_python_casadi else "FALSE"),
99103
f"-DPYBAMM_IDAKLU_EXPR_CASADI={idaklu_expr_casadi}",
104+
f"-Dpybind11_DIR={pybind11_cmake_dir}",
100105
]
101106
if self.suitesparse_root:
102107
cmake_args.append(
@@ -231,7 +236,7 @@ def run(self):
231236

232237

233238
ext_modules = [
234-
Extension(
239+
Pybind11Extension(
235240
name="pybammsolvers.idaklu",
236241
# The sources list should mirror the list in CMakeLists.txt
237242
sources=[
@@ -267,6 +272,7 @@ def run(self):
267272
"src/pybammsolvers/idaklu_source/Options.cpp",
268273
"src/pybammsolvers/idaklu.cpp",
269274
],
275+
include_dirs=[str(Path(default_lib_dir) / "include"), pybind11.get_include()],
270276
)
271277
]
272278

0 commit comments

Comments
 (0)