From 15b5055770c9c20b047b03ea0487278b47cab42d Mon Sep 17 00:00:00 2001 From: Dan Foreman-Mackey Date: Fri, 20 Oct 2023 07:53:35 -0400 Subject: [PATCH] Fix FSPS submodule inclusion in sdist and add build check (#242) * Fixing CI sdist build to include the submodule * Adding check to Cmake for submodule --- .github/workflows/release.yml | 1 + src/fsps/CMakeLists.txt | 113 ++++++++++++++++++---------------- 2 files changed, 60 insertions(+), 54 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8e096c5..cc5ae50 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -48,6 +48,7 @@ jobs: steps: - uses: actions/checkout@v4 with: + submodules: true fetch-depth: 0 - uses: actions/setup-python@v4 with: diff --git a/src/fsps/CMakeLists.txt b/src/fsps/CMakeLists.txt index 42632af..cd32399 100644 --- a/src/fsps/CMakeLists.txt +++ b/src/fsps/CMakeLists.txt @@ -1,74 +1,79 @@ +if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/sps_vars.f90") + message(FATAL_ERROR "The source code in the FSPS submodule was not found." + "Please run 'git submodule update --init' to initialize the submodule.") +endif() + # Generate the f2py wrappers set(F2PY_SOURCES - "${CMAKE_CURRENT_BINARY_DIR}/_fspsmodule.c" - "${CMAKE_CURRENT_BINARY_DIR}/_fsps-f2pywrappers2.f90" + "${CMAKE_CURRENT_BINARY_DIR}/_fspsmodule.c" + "${CMAKE_CURRENT_BINARY_DIR}/_fsps-f2pywrappers2.f90" ) add_custom_command( OUTPUT ${F2PY_SOURCES} DEPENDS fsps.f90 VERBATIM COMMAND "${Python_EXECUTABLE}" -m numpy.f2py - "${CMAKE_CURRENT_SOURCE_DIR}/fsps.f90" -m _fsps --lower - --build-dir "${CMAKE_CURRENT_BINARY_DIR}") + "${CMAKE_CURRENT_SOURCE_DIR}/fsps.f90" -m _fsps --lower + --build-dir "${CMAKE_CURRENT_BINARY_DIR}") # List out the explicit FSPS sources; we don't use a glob here since # the 'src' directory includes some executables that we don't want to # include here. set( - FSPS_SOURCES - "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/sps_vars.f90" - "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/sps_utils.f90" - "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/add_agb_dust.f90" - "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/add_bs.f90" - "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/add_dust.f90" - "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/add_nebular.f90" - "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/add_remnants.f90" - "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/add_xrb.f90" - "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/agn_dust.f90" - "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/attn_curve.f90" - "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/compsp.f90" - "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/csp_gen.f90" - "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/funcint.f90" - "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/get_lumdist.f90" - "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/get_tuniv.f90" - "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/getindx.f90" - "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/getmags.f90" - "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/getspec.f90" - "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/igm_absorb.f90" - "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/imf.f90" - "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/imf_weight.f90" - "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/intsfwght.f90" - "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/linterp.f90" - "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/linterparr.f90" - "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/locate.f90" - "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/mod_gb.f90" - "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/mod_hb.f90" - "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/pz_convol.f90" - "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/sbf.f90" - "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/setup_tabular_sfh.f90" - "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/sfh_weight.f90" - "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/sfhinfo.f90" - "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/sfhlimit.f90" - "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/sfhstat.f90" - "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/smoothspec.f90" - "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/spec_bin.f90" - "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/sps_setup.f90" - "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/ssp_gen.f90" - "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/tsum.f90" - "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/vacairconv.f90" - "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/write_isochrone.f90" - "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/ztinterp.f90" + FSPS_SOURCES + "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/sps_vars.f90" + "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/sps_utils.f90" + "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/add_agb_dust.f90" + "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/add_bs.f90" + "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/add_dust.f90" + "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/add_nebular.f90" + "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/add_remnants.f90" + "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/add_xrb.f90" + "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/agn_dust.f90" + "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/attn_curve.f90" + "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/compsp.f90" + "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/csp_gen.f90" + "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/funcint.f90" + "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/get_lumdist.f90" + "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/get_tuniv.f90" + "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/getindx.f90" + "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/getmags.f90" + "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/getspec.f90" + "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/igm_absorb.f90" + "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/imf.f90" + "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/imf_weight.f90" + "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/intsfwght.f90" + "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/linterp.f90" + "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/linterparr.f90" + "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/locate.f90" + "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/mod_gb.f90" + "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/mod_hb.f90" + "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/pz_convol.f90" + "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/sbf.f90" + "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/setup_tabular_sfh.f90" + "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/sfh_weight.f90" + "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/sfhinfo.f90" + "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/sfhlimit.f90" + "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/sfhstat.f90" + "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/smoothspec.f90" + "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/spec_bin.f90" + "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/sps_setup.f90" + "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/ssp_gen.f90" + "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/tsum.f90" + "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/vacairconv.f90" + "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/write_isochrone.f90" + "${CMAKE_CURRENT_SOURCE_DIR}/libfsps/src/ztinterp.f90" ) # Define the Python library python_add_library( - _fsps - MODULE - "${CMAKE_CURRENT_SOURCE_DIR}/fsps.f90" - ${FSPS_SOURCES} - ${F2PY_SOURCES} - "${F2PY_INCLUDE_DIR}/fortranobject.c" - WITH_SOABI) + _fsps + MODULE + "${CMAKE_CURRENT_SOURCE_DIR}/fsps.f90" + ${FSPS_SOURCES} + ${F2PY_SOURCES} + "${F2PY_INCLUDE_DIR}/fortranobject.c" + WITH_SOABI) target_link_libraries(_fsps PUBLIC Python::NumPy) target_include_directories(_fsps PUBLIC "${F2PY_INCLUDE_DIR}") install(TARGETS _fsps DESTINATION ${SKBUILD_PROJECT_NAME})