Skip to content

Commit fa939dc

Browse files
committed
Merge branch 'cvode_7.1.1' into SoybeanParameterization
2 parents 77224bf + cea24e6 commit fa939dc

File tree

19 files changed

+760
-267
lines changed

19 files changed

+760
-267
lines changed

.github/workflows/test-suite.yml

Lines changed: 39 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ jobs:
2222
with-elf: [false]
2323
with-valgrind: [false, true]
2424
with-mpi: [false]
25+
with-python: [false]
2526
include:
2627
- sundials-version: "5.7.0"
2728
os: ubuntu-latest
@@ -30,41 +31,55 @@ jobs:
3031
with-elf: false
3132
with-valgrind: false
3233
with-mpi: false
34+
with-python: false
3335
- sundials-version: "6.7.0"
3436
os: ubuntu-latest
3537
with-coverage: false
3638
with-asan: false
3739
with-elf: false
3840
with-valgrind: false
3941
with-mpi: false
42+
with-python: false
4043
- sundials-version: "7.1.1"
4144
os: ubuntu-latest
4245
with-coverage: false
4346
with-asan: false
4447
with-elf: false
4548
with-valgrind: false
4649
with-mpi: false
50+
with-python: false
4751
- sundials-version: latest
4852
os: ubuntu-latest
4953
with-coverage: false
5054
with-asan: false
5155
with-elf: false
5256
with-valgrind: false
5357
with-mpi: true
58+
with-python: false
5459
- sundials-version: "6.7.0"
5560
os: ubuntu-latest
5661
with-coverage: false
5762
with-asan: false
5863
with-elf: false
5964
with-valgrind: false
6065
with-mpi: true
66+
with-python: false
6167
- sundials-version: "7.1.1"
6268
os: ubuntu-latest
6369
with-coverage: false
6470
with-asan: false
6571
with-elf: false
6672
with-valgrind: false
6773
with-mpi: true
74+
with-python: false
75+
- sundials-version: latest
76+
os: ubuntu-latest
77+
with-coverage: false
78+
with-asan: false
79+
with-elf: false
80+
with-valgrind: false
81+
with-mpi: false
82+
with-python: true
6883
exclude:
6984
- os: windows-latest
7085
with-asan: true
@@ -212,6 +227,11 @@ jobs:
212227
echo "CMAKE_ARGS=-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON" >> "$GITHUB_ENV"
213228
echo "CMAKE_ARGS_TEST=-DBUILD_TESTS=ON" >> "$GITHUB_ENV"
214229
echo "TEST_FLAGS=-C ${CMAKE_BUILD_TYPE_TEST} --output-on-failure -VV" >> "$GITHUB_ENV"
230+
echo "BUILD_ARGS=--config ${CMAKE_BUILD_TYPE_TEST}" >> "$GITHUB_ENV"
231+
- name: Set flags to build in parallel (UNIX)
232+
if: matrix.os != 'windows-latest'
233+
run: |
234+
echo "BUILD_ARGS=${{ env.BUILD_ARGS }} -- -j 4" >> "$GITHUB_ENV"
215235
- name: Coverage config flags
216236
if: matrix.with-coverage == true && matrix.os != 'windows-latest'
217237
run: |
@@ -257,21 +277,15 @@ jobs:
257277
mkdir build
258278
cd build
259279
which cmake
260-
cmake .. ${{ env.CMAKE_ARGS }} ${{ env.CMAKE_ARGS_NO_PYTHON }} ${{ env.CMAKE_ARGS_TEST }}
280+
cmake .. ${{ env.CMAKE_ARGS }} ${{ env.CMAKE_ARGS_TEST }}
261281
262282
###################################
263283
# Build CXX
264284
###################################
265-
- name: Build C++ & C in parallel (CONDA, UNIX)
266-
if: matrix.os != 'windows-latest'
285+
- name: Build C++ & C
267286
run: |
268287
cd build
269-
cmake --build . --config ${{ env.CMAKE_BUILD_TYPE_TEST }} -- -j 4
270-
- name: Build C++ & C in serial (CONDA, WINDOWS)
271-
if: matrix.os == 'windows-latest'
272-
run: |
273-
cd build
274-
cmake --build . --config ${{ env.CMAKE_BUILD_TYPE_TEST }}
288+
cmake --build . ${{ env.BUILD_ARGS }}
275289
276290
###################################
277291
# Test CXX
@@ -299,26 +313,25 @@ jobs:
299313
###################################
300314
# Build Python
301315
###################################
302-
# - name: Set CMAKE_ARGS for Python build
303-
# run: |
304-
# echo "OLD_CMAKE_ARGS=${{ env.CMAKE_ARGS }}" >> "$GITHUB_ENV"
305-
# echo "CMAKE_ARGS=${{ env.CMAKE_ARGS }} -DBUILD_PYTHON=ON" >> "$GITHUB_ENV"
306-
# - name: Build Python (CONDA)
307-
# run: |
308-
# cd build
309-
# which cmake
310-
# cmake .. ${{ env.CMAKE_ARGS }} ${{ env.CMAKE_ARGS_TEST }}
311-
# - name: Unset CMAKE_ARGS for Python build
312-
# run: |
313-
# echo "CMAKE_ARGS=${{ env.OLD_CMAKE_ARGS }}" >> "$GITHUB_ENV"
316+
- name: Configure Python
317+
if: matrix.with-python == true
318+
run: |
319+
cd build
320+
cmake .. -DBUILD_PYTHON=ON ${{ env.CMAKE_ARGS }}
321+
- name: Build & install Python
322+
if: matrix.with-python == true
323+
run: |
324+
cd build
325+
cmake --build . --target pyPhotosynthesis ${{ env.BUILD_ARGS }}
326+
cmake --install . --prefix /home/runner/miniconda3/envs/ephoto --component Python
314327
315328
###################################
316329
# Test Python
317330
###################################
318-
# - name: Test Python Interfaces (CONDA)
319-
# if: matrix.with-elf == false && matrix.with-valgrind == false
320-
# run: |
321-
# pytest -sv tests/python
331+
- name: Test Python Interfaces
332+
if: matrix.with-python == true
333+
run: |
334+
pytest -sv tests/python
322335
323336
###################################
324337
# Docs tests
@@ -335,7 +348,7 @@ jobs:
335348
if: matrix.with-coverage == true && matrix.os != 'windows-latest'
336349
uses: codecov/codecov-action@v4
337350
with:
338-
name: ${{ matrix.os }}-${{ matrix.with-coverage }}-${{ matrix.with-asan }}-${{ matrix.with-elf }}-${{ matrix.with-valgrind }}
351+
name: ${{ matrix.os }}-${{ matrix.sundials-version }}-${{ matrix.with-coverage }}-${{ matrix.with-asan }}-${{ matrix.with-elf }}-${{ matrix.with-valgrind }}-${{ matrix.with-mpi }}-${{ matrix.with-python }}
339352
token: ${{ secrets.CODECOV_TOKEN }}
340353
file: coverage/coverage.info
341354
functionalities: gcov

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,6 @@ Doxyfile
6161
doc/html
6262
doc/latex
6363

64-
*~
64+
*~
65+
66+
__pycache__

CMakeLists.txt

Lines changed: 80 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@
2222
# *
2323
# **********************************************************************************************************************************************
2424

25-
cmake_minimum_required(VERSION 3.5)
25+
cmake_minimum_required(VERSION 3.10)
26+
27+
if(POLICY CMP0167)
28+
cmake_policy(SET CMP0167 NEW)
29+
endif()
2630

2731
project(ePhotosynthesisProject LANGUAGES C CXX)
2832

@@ -63,7 +67,7 @@ else()
6367
endif()
6468
# Prohibit in-source build
6569
if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
66-
message(FATAL_ERROR "In-source build prohibited.")
70+
message(FATAL_ERROR "In-source build prohibited.\nCMAKE_SOURCE_DIR = ${CMAKE_SOURCE_DIR}\nCMAKE_BINARY_DIR = ${CMAKE_BINARY_DIR}")
6771
endif("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
6872

6973
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${PROJECT_SOURCE_DIR}/cmake")
@@ -243,12 +247,14 @@ install(
243247
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
244248
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
245249
PUBLIC_HEADER DESTINATION EPHOTOSYNTHESIS_INSTALL_INCLUDEDIR
250+
COMPONENT CXX
246251
)
247252
install(
248253
EXPORT ePhotosynthesisTargets
249254
FILE ePhotosynthesisTargets.cmake
250255
NAMESPACE ePhotosynthesis::
251256
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ePhotosynthesis
257+
COMPONENT CXX
252258
)
253259
include(CMakePackageConfigHelpers)
254260
write_basic_package_version_file(
@@ -264,10 +270,12 @@ install(
264270
FILES "${CMAKE_CURRENT_BINARY_DIR}/ePhotosynthesisConfig.cmake"
265271
"${CMAKE_CURRENT_BINARY_DIR}/ePhotosynthesisConfigVersion.cmake"
266272
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ePhotosynthesis
273+
COMPONENT CXX
267274
)
268275
install(
269276
FILES ${CMAKE_CURRENT_BINARY_DIR}/ePhotosynthesis_export.h
270277
DESTINATION ${EPHOTOSYNTHESIS_INSTALL_INCLUDEDIR}
278+
COMPONENT CXX
271279
)
272280
# install(
273281
# DIRECTORY param
@@ -324,6 +332,7 @@ if(BUILD_DOCS)
324332
DIRECTORY ${DOXYGEN_BUILD_DIR}/
325333
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/doc/ephotosynthesis
326334
OPTIONAL
335+
COMPONENT docs
327336
)
328337
endif()
329338

@@ -504,15 +513,73 @@ endif()
504513
##########
505514

506515
if(BUILD_PYTHON)
507-
find_package(PythonInterp 3)
508-
find_package(PythonLibs 3 REQUIRED)
509-
add_library(pyPhotosynthesis MODULE ${SOURCES})
510-
include_directories(${PYTHON_INCLUDE_DIRS})
511-
find_package(Boost 1.36.0 REQUIRED COMPONENTS regex python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR})
512-
target_link_libraries(pyPhotosynthesis boost_python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR})
513-
target_link_libraries(pyPhotosynthesis boost_regex)
514-
target_link_libraries(pyPhotosynthesis ${PYTHON_LIBRARIES})
515-
target_link_libraries(pyPhotosynthesis ${SUNDIALS_LIBRARIES})
516-
target_compile_options(pyPhotosynthesis PRIVATE -DBUILD_PYTHON)
517-
set_target_properties(pyPhotosynthesis PROPERTIES PREFIX "")
516+
set(PYTHON_PACKAGE_NAME ePhotosynthesis)
517+
set(PYTHON_LIBRARY_NAME pyPhotosynthesis)
518+
find_package(
519+
Python REQUIRED COMPONENTS
520+
Interpreter Development.Module
521+
)
522+
find_package(
523+
Boost 1.36.0 REQUIRED COMPONENTS
524+
regex python${Python_VERSION_MAJOR}${Python_VERSION_MINOR}
525+
)
526+
add_library(${PYTHON_LIBRARY_NAME} MODULE ${SOURCES})
527+
target_link_libraries(
528+
${PYTHON_LIBRARY_NAME}
529+
${Boost_LIBRARIES}
530+
Python::Module
531+
${SUNDIALS_LIBRARIES}
532+
)
533+
target_include_directories(
534+
${PYTHON_LIBRARY_NAME} PUBLIC
535+
${Boost_INCLUDE_DIRS}
536+
${Python_INCLUDE_DIRS}
537+
${SUNDIALS_INCLUDE_DIRS}
538+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
539+
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
540+
$<INSTALL_INTERFACE:include/ePhotosynthesis>
541+
)
542+
target_compile_options(
543+
${PYTHON_LIBRARY_NAME} PRIVATE -DBUILD_PYTHON
544+
-DPYTHON_LIBRARY_NAME=${PYTHON_LIBRARY_NAME}
545+
)
546+
set_target_properties(${PYTHON_LIBRARY_NAME} PROPERTIES PREFIX "")
547+
548+
# Tests (requires the Python package actually be installed)
549+
add_test(NAME python_tests
550+
COMMAND pytest -svx ${PROJECT_SOURCE_DIR}/tests/python)
551+
552+
# Installation
553+
# set(PYTHON_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR})
554+
cmake_path(
555+
APPEND CMAKE_CURRENT_BINARY_DIR ${PYTHON_PACKAGE_NAME}
556+
OUTPUT_VARIABLE PYTHON_BUILD_DIR
557+
)
558+
cmake_path(
559+
APPEND Python_SITEARCH ${PYTHON_PACKAGE_NAME}
560+
OUTPUT_VARIABLE PYTHON_INSTALL_DIR
561+
)
562+
message(STATUS "Python_SITEARCH = ${Python_SITEARCH}")
563+
message(STATUS "PYTHON_PACKAGE_NAME = ${PYTHON_PACKAGE_NAME}")
564+
message(STATUS "PYTHON_INSTALL_DIR = ${PYTHON_INSTALL_DIR}")
565+
message(STATUS "PYTHON_BUILD_DIR = ${PYTHON_BUILD_DIR}")
566+
install(
567+
TARGETS ${PYTHON_LIBRARY_NAME}
568+
DESTINATION "${PYTHON_INSTALL_DIR}"
569+
COMPONENT Python
570+
)
571+
set_target_properties(
572+
${PYTHON_LIBRARY_NAME} PROPERTIES
573+
LIBRARY_OUTPUT_DIRECTORY ${PYTHON_BUILD_DIR}
574+
RUNTIME_OUTPUT_DIRECTORY ${PYTHON_BUILD_DIR}
575+
)
576+
configure_file(
577+
cmake/__init__.py.in
578+
${PYTHON_BUILD_DIR}/__init__.py @ONLY
579+
)
580+
install(
581+
FILES ${PYTHON_BUILD_DIR}/__init__.py
582+
DESTINATION "${PYTHON_INSTALL_DIR}"
583+
COMPONENT Python
584+
)
518585
endif()

README.md

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ All of the packages required to build & run the library, tests, & documentation
1919
- [GoogleTest](https://google.github.io/googletest/) - (optional) needed to build the tests
2020
- [LCOV](https://wiki.documentfoundation.org/Development/Lcov) - (optional) needed to get test coverage
2121

22-
### Building
22+
### Building the C++ library & executable
2323
This can be built using a conda environment. This way, the cmake should be able to find the boost and sundials dependencies automatically. When using conda to manage the dependencies:
2424

2525
1. Be sure to activate the related env the next time after login.
@@ -37,6 +37,33 @@ cmake --build .
3737
cmake --install . (if desired)
3838
```
3939

40+
### Building the Python extension
41+
Similar to building the C++ library & executable, with the exception that the Python cmake target (pyPhotosynthesis) should be passed to the build command and the ``Python`` component should be specified in the install command if only the Python extension should be installed.
42+
43+
```
44+
mkdir build
45+
cd build
46+
cmake .. -DBUILD_PYTHON:BOOL=ON
47+
cmake --build . --target pyPhotosynthesis
48+
cmake --install . --component Python (if desired)
49+
```
50+
51+
The Python extension has the name ``ePhotosynthesis`` and can be used to run drivers from Python. E.g.
52+
53+
```
54+
import ePhotosynthesis
55+
theVars = ePhotosynthesis.Variables()
56+
theVars.readParam("InputEvn.txt")
57+
theVars.readParam("InputATPCost.txt")
58+
theVars.readEnzymeAct("InputEnzyme.txt")
59+
theVars.readGRN("InputGRNC.txt")
60+
theVars.RUBISCOMETHOD = 2
61+
theVars.debuglevel = 0
62+
ePhotosynthesis.modules.PR.setRUBISCOTOTAL(3)
63+
drv = ePhotosynthesis.drivers.EPSDriver(theVars, 0, 1, 5000, 750, 1e-5, 1e-4, 1, 1 25.0)
64+
results = drv.run()
65+
```
66+
4067
### Documentation
4168
The documentation is not automatically built. To build the docs run the following from the build directory (requires Doxygen)
4269
```
@@ -47,7 +74,7 @@ cmake --build . --target docs
4774
This will build the documentation and put the resulting files in the doc directory.
4875

4976
### Tests
50-
The tests are not automatically built. To build and run the tests, can be run the following from the build directory (requires GoogleTest)
77+
The tests are not automatically built. To build and run the tests, can be run the following from the build directory (requires GoogleTest). If ``-DBUILD_PYTHON:BOOL=ON`` is passed to the configuration step, the Python tests will also be run.
5178
```
5279
cmake .. -DBUILD_TESTS:BOOL=ON
5380
cmake --build .

0 commit comments

Comments
 (0)