caliper: add +python variant with pybind11 bindings (#47031)

* Updates Caliper recipe to build the new Python bindings

* Implements setup_run_environment for Caliper to update PYTHONPATH
This commit is contained in:
Ian Lumsden 2024-10-16 22:43:34 -04:00 committed by GitHub
parent 178a8bbdc5
commit 1eb2cb97ad
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -101,6 +101,8 @@ class Caliper(CachedCMakePackage, CudaPackage, ROCmPackage):
variant("vtune", default=False, description="Enable Intel Vtune support") variant("vtune", default=False, description="Enable Intel Vtune support")
variant("kokkos", default=True, when="@2.3.0:", description="Enable Kokkos profiling support") variant("kokkos", default=True, when="@2.3.0:", description="Enable Kokkos profiling support")
variant("tests", default=False, description="Enable tests") variant("tests", default=False, description="Enable tests")
# TODO change the 'when' argument for the next release of Caliper
variant("python", default=False, when="@master", description="Build Python bindings")
depends_on("adiak@0.1:0", when="@2.2:2.10 +adiak") depends_on("adiak@0.1:0", when="@2.2:2.10 +adiak")
depends_on("adiak@0.4:0", when="@2.11: +adiak") depends_on("adiak@0.4:0", when="@2.11: +adiak")
@ -121,6 +123,9 @@ class Caliper(CachedCMakePackage, CudaPackage, ROCmPackage):
depends_on("cmake", type="build") depends_on("cmake", type="build")
depends_on("python", type="build") depends_on("python", type="build")
depends_on("python@3", when="+python", type=("build", "link", "run"))
depends_on("py-pybind11", when="+python", type=("build", "link", "run"))
# sosflow support not yet in 2.0 # sosflow support not yet in 2.0
conflicts("+sosflow", "@2.0.0:2.11") conflicts("+sosflow", "@2.0.0:2.11")
conflicts("+adiak", "@:2.1") conflicts("+adiak", "@:2.1")
@ -228,6 +233,7 @@ def initconfig_package_entries(self):
entries.append(cmake_cache_option("WITH_KOKKOS", spec.satisfies("+kokkos"))) entries.append(cmake_cache_option("WITH_KOKKOS", spec.satisfies("+kokkos")))
entries.append(cmake_cache_option("WITH_VARIORUM", spec.satisfies("+variorum"))) entries.append(cmake_cache_option("WITH_VARIORUM", spec.satisfies("+variorum")))
entries.append(cmake_cache_option("WITH_VTUNE", spec.satisfies("+vtune"))) entries.append(cmake_cache_option("WITH_VTUNE", spec.satisfies("+vtune")))
entries.append(cmake_cache_option("WITH_PYTHON_BINDINGS", spec.satisfies("+python")))
# -DWITH_CALLPATH was renamed -DWITH_LIBUNWIND in 2.5 # -DWITH_CALLPATH was renamed -DWITH_LIBUNWIND in 2.5
callpath_flag = "LIBUNWIND" if spec.satisfies("@2.5:") else "CALLPATH" callpath_flag = "LIBUNWIND" if spec.satisfies("@2.5:") else "CALLPATH"
@ -238,6 +244,11 @@ def initconfig_package_entries(self):
def cmake_args(self): def cmake_args(self):
return [] return []
def setup_run_environment(self, env):
if self.spec.satisfies("+python"):
env.prepend_path("PYTHONPATH", self.spec.prefix.join(python_platlib))
env.prepend_path("PYTHONPATH", self.spec.prefix.join(python_purelib))
@run_after("install") @run_after("install")
def cache_test_sources(self): def cache_test_sources(self):
"""Copy the example source files after the package is installed to an """Copy the example source files after the package is installed to an