Skip to content

Commit

Permalink
Specify cmake build types and require cmake-build-extension==0.6.0 (#…
Browse files Browse the repository at this point in the history
…2445)

* Require https://github.com/diegoferigo/cmake-build-extension/releases/tag/v0.6.0
* Specify cmake build types properly 
  Closes #2447 
  Closes #2442
  • Loading branch information
dweindl committed May 16, 2024
1 parent 59256b4 commit 7f7be0f
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 8 deletions.
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ if("$ENV{ENABLE_AMICI_DEBUGGING}" OR "$ENV{ENABLE_GCOV_COVERAGE}")
else()
add_compile_options(-O0 -g)
endif()
set(CMAKE_BUILD_TYPE "Debug")
endif()

# coverage options
Expand Down
6 changes: 6 additions & 0 deletions python/sdist/amici/setup.template.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ def get_extension() -> CMakeExtension:
else:
os.environ["CMAKE_BUILD_PARALLEL_LEVEL"] = "1"

debug_build = os.getenv("ENABLE_AMICI_DEBUGGING", "").lower() in [
"1",
"true",
] or os.getenv("ENABLE_GCOV_COVERAGE", "").lower() in ["1", "true"]

return CMakeExtension(
name="model_ext",
source_dir=os.getcwd(),
Expand All @@ -37,6 +42,7 @@ def get_extension() -> CMakeExtension:
"-DAMICI_PYTHON_BUILD_EXT_ONLY=ON",
f"-DPython3_EXECUTABLE={Path(sys.executable).as_posix()}",
],
cmake_build_type="Debug" if debug_build else "Release",
)


Expand Down
4 changes: 2 additions & 2 deletions python/sdist/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ requires = [
# cf. discussion at https://github.com/numpy/numpy/issues/5888
# (https://github.com/scipy/oldest-supported-numpy/)
"oldest-supported-numpy",
"cmake-build-extension==0.5.1",
"cmake-build-extension==0.6.0",
]
build-backend = "setuptools.build_meta"

Expand All @@ -21,7 +21,7 @@ dynamic = ["version"]
description = "Advanced multi-language Interface to CVODES and IDAS"
requires-python = ">=3.10"
dependencies = [
"cmake-build-extension==0.5.1",
"cmake-build-extension==0.6.0",
"sympy>=1.9",
"numpy>=1.19.3; python_version=='3.9'",
"numpy>=1.21.4; python_version>='3.10'",
Expand Down
5 changes: 5 additions & 0 deletions python/sdist/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ def get_extensions():
],
)
# AMICI
debug_build = os.getenv("ENABLE_AMICI_DEBUGGING", "").lower() in [
"1",
"true",
] or os.getenv("ENABLE_GCOV_COVERAGE", "").lower() in ["1", "true"]
amici_ext = CMakeExtension(
name="amici",
install_prefix="amici",
Expand All @@ -153,6 +157,7 @@ def get_extensions():
"-DAMICI_PYTHON_BUILD_EXT_ONLY=ON",
f"-DPython3_EXECUTABLE={Path(sys.executable).as_posix()}",
],
cmake_build_type="Debug" if debug_build else "Release",
)
# Order matters!
return [suitesparse_config, amd, btf, colamd, klu, sundials, amici_ext]
Expand Down
5 changes: 3 additions & 2 deletions python/tests/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,9 @@ def test_cmake_compilation(sbml_example_presimulation_module):
amici_dir = (Path(__file__).parents[2] / "build").absolute()
cmd = (
f"set -e; "
f"cmake -S {source_dir} -B '{build_dir}' -DAmici_DIR={amici_dir}; "
f"cmake --build '{build_dir}'"
f"cmake -S {source_dir} -B '{build_dir}' "
f"-DCMAKE_BUILD_TYPE=Debug -DAmici_DIR={amici_dir}; "
f"cmake --build '{build_dir}' --config Debug"
)

try:
Expand Down
3 changes: 2 additions & 1 deletion scripts/buildAmici.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ mkdir -p "${amici_build_dir}"
cd "${amici_build_dir}"

if [ "${GITHUB_ACTIONS:-}" = true ] ||
[ "${ENABLE_AMICI_DEBUGGING:-}" = TRUE ]; then
[ "${ENABLE_AMICI_DEBUGGING:-}" = TRUE ] ||
[ "${ENABLE_GCOV_COVERAGE:-}" = TRUE ]; then
# Running on CI server
build_type="Debug"
# exceptions instead of terminate()
Expand Down
2 changes: 1 addition & 1 deletion scripts/installAmiciSource.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ fi
export PYTHON_EXECUTABLE="${AMICI_PATH}/venv/bin/python"

python -m pip install --upgrade pip wheel
python -m pip install --upgrade pip setuptools cmake_build_extension==0.5.1 numpy
python -m pip install --upgrade pip setuptools cmake_build_extension==0.6.0 numpy
python -m pip install git+https://github.com/FFroehlich/pysb@fix_pattern_matching # pin to PR for SPM with compartments
AMICI_BUILD_TEMP="${AMICI_PATH}/python/sdist/build/temp" \
python -m pip install --verbose -e "${AMICI_PATH}/python/sdist[petab,test,vis]" --no-build-isolation
Expand Down
5 changes: 4 additions & 1 deletion src/CMakeLists.template.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ endif()
find_package(Amici TPL_AMICI_VERSION REQUIRED HINTS
${CMAKE_CURRENT_LIST_DIR}/../../build)
message(STATUS "Found AMICI ${Amici_DIR}")
set_target_properties(Upstream::amici PROPERTIES
MAP_IMPORTED_CONFIG_RELWITHDEBINFO RelWithDebInfo;Release;
MAP_IMPORTED_CONFIG_RELEASE Release
MAP_IMPORTED_CONFIG_DEBUG Debug;RelWithDebInfo;)

# Debug build?
if("$ENV{ENABLE_AMICI_DEBUGGING}" OR "$ENV{ENABLE_GCOV_COVERAGE}")
Expand All @@ -47,7 +51,6 @@ if("$ENV{ENABLE_AMICI_DEBUGGING}" OR "$ENV{ENABLE_GCOV_COVERAGE}")
else()
add_compile_options(-O0 -g)
endif()
set(CMAKE_BUILD_TYPE "Debug")
endif()

# coverage options
Expand Down

0 comments on commit 7f7be0f

Please sign in to comment.