diff --git a/python/sdist/setup.py b/python/sdist/setup.py index 4850763926..9a7889ff97 100755 --- a/python/sdist/setup.py +++ b/python/sdist/setup.py @@ -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", @@ -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 @@ -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():