Skip to content

Commit

Permalink
Build SuiteSparse as a single extension
Browse files Browse the repository at this point in the history
Previously, we had to build the different SuiteSparse subprojects separately.
Meanwhile, we can do that together. This is more concise, and saves a some
extra cmake configuration runs, leading to faster package installation.
  • Loading branch information
dweindl committed Sep 30, 2024
1 parent 98488fa commit 9e4aa5a
Showing 1 changed file with 18 additions and 63 deletions.
81 changes: 18 additions & 63 deletions python/sdist/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,80 +52,40 @@ def get_extensions():
build_type = "Debug" if debug_build else "Release"

# SuiteSparse Config
suitesparse_config = CMakeExtension(
name="SuiteSparse_config",
suitesparse = CMakeExtension(
name="SuiteSparse",
install_prefix="amici",
source_dir="amici/ThirdParty/SuiteSparse/SuiteSparse_config",
source_dir="amici/ThirdParty/SuiteSparse",
cmake_build_type=build_type,
cmake_configure_options=[
*global_cmake_configure_options,
"-DCMAKE_POSITION_INDEPENDENT_CODE=ON",
"-DBUILD_SHARED_LIBS=OFF",
"-DBUILD_TESTING=OFF",
# Building SuiteSparse_config does not require a BLAS
# we just set BLAS_LIBRARIES to skip the search,
# the value is not used
# "-DBLA_VENDOR=All",
"-DBLAS_LIBRARIES=dummy",
"-DSUITESPARSE_USE_64BIT_BLAS=ON",
"-DSUITESPARSE_ENABLE_PROJECTS=amd;btf;colamd;klu",
"-DSUITESPARSE_USE_CUDA=OFF",
"-DSUITESPARSE_USE_FORTRAN=OFF",
],
)
# SuiteSparse AMD
amd = CMakeExtension(
name="amd",
install_prefix="amici",
source_dir="amici/ThirdParty/SuiteSparse/AMD",
cmake_build_type=build_type,
cmake_configure_options=[
*global_cmake_configure_options,
"-DBUILD_SHARED_LIBS=OFF",
"-DCMAKE_POSITION_INDEPENDENT_CODE=ON",
"-DSUITESPARSE_USE_FORTRAN=OFF",
],
)
# SuiteSparse BTF
btf = CMakeExtension(
name="btf",
install_prefix="amici",
source_dir="amici/ThirdParty/SuiteSparse/BTF",
cmake_build_type=build_type,
cmake_configure_options=[
*global_cmake_configure_options,
"-DSUITESPARSE_USE_FORTRAN=OFF",
"-DBUILD_SHARED_LIBS=OFF",
"-DCMAKE_POSITION_INDEPENDENT_CODE=ON",
],
)
# SuiteSparse COLAMD
colamd = CMakeExtension(
name="colamd",
install_prefix="amici",
source_dir="amici/ThirdParty/SuiteSparse/COLAMD",
cmake_build_type=build_type,
cmake_configure_options=[
*global_cmake_configure_options,
"-DSUITESPARSE_USE_FORTRAN=OFF",
"-DBUILD_SHARED_LIBS=OFF",
"-DCMAKE_POSITION_INDEPENDENT_CODE=ON",
],
)
# SuiteSparse KLU
klu = CMakeExtension(
name="klu",
install_prefix="amici",
source_dir="amici/ThirdParty/SuiteSparse/KLU",
cmake_build_type=build_type,
cmake_configure_options=[
*global_cmake_configure_options,
"-DSUITESPARSE_USE_PYTHON=OFF",
"-DSUITESPARSE_USE_OPENMP=OFF",
"-DSUITESPARSE_CONFIG_USE_OPENMP=OFF",
"-DCHOLMOD_CAMD=OFF",
"-DKLU_USE_CHOLMOD=OFF",
"-DSUITESPARSE_USE_CUDA=OFF",
"-DSUITESPARSE_USE_FORTRAN=OFF",
"-DBUILD_SHARED_LIBS=OFF",
"-DCMAKE_POSITION_INDEPENDENT_CODE=ON",
],
)
# SUNDIALS
# We need the potentially temporary and unpredictable build path
# to use artifacts from other extensions here. `${build_dir}` will
# be replaced by the actual path by `AmiciBuildCMakeExtension`
# before being passed to CMake.
cmake_prefix_path = "${build_dir}/amici"
if cmake_prefix_path_env := os.getenv("CMAKE_PREFIX_PATH", ""):
cmake_prefix_path += f";{cmake_prefix_path_env}"
sundials = CMakeExtension(
name="sundials",
install_prefix="amici",
Expand All @@ -144,12 +104,7 @@ def get_extensions():
"-DEXAMPLES_ENABLE_C=OFF",
"-DEXAMPLES_INSTALL=OFF",
"-DENABLE_KLU=ON",
# We need the potentially temporary and unpredictable build path
# to use artifacts from other extensions here. `${build_dir}` will
# be replaced by the actual path by `AmiciBuildCMakeExtension`
# before being passed to CMake.
"-DKLU_LIBRARY_DIR='${build_dir}/amici/lib'",
"-DKLU_INCLUDE_DIR='${build_dir}/amici/include/suitesparse'",
f"-DCMAKE_PREFIX_PATH='{cmake_prefix_path}'",
],
)
# AMICI
Expand All @@ -170,7 +125,7 @@ def get_extensions():
],
)
# Order matters!
return [suitesparse_config, amd, btf, colamd, klu, sundials, amici_ext]
return [suitesparse, sundials, amici_ext]


def main():
Expand Down

0 comments on commit 9e4aa5a

Please sign in to comment.