From 240f9bba196544ae86454ec894bab2de39801037 Mon Sep 17 00:00:00 2001 From: Ingmar Schoegl Date: Tue, 29 Nov 2022 15:14:16 -0600 Subject: [PATCH] [Python] Add utility to query HDF support --- interfaces/cython/cantera/_utils.pxd | 1 + interfaces/cython/cantera/_utils.pyx | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/interfaces/cython/cantera/_utils.pxd b/interfaces/cython/cantera/_utils.pxd index bb3abb8193..c5f9789426 100644 --- a/interfaces/cython/cantera/_utils.pxd +++ b/interfaces/cython/cantera/_utils.pxd @@ -72,6 +72,7 @@ cdef extern from "cantera/base/global.h" namespace "Cantera": cdef void Cxx_suppress_thermo_warnings "Cantera::suppress_thermo_warnings" (cbool) cdef void Cxx_use_legacy_rate_constants "Cantera::use_legacy_rate_constants" (cbool) cdef string CxxGitCommit "Cantera::gitCommit" () + cdef cbool CxxUsesHighFive "Cantera::usesHighFive" () cdef cbool CxxDebugModeEnabled "Cantera::debugModeEnabled" () diff --git a/interfaces/cython/cantera/_utils.pyx b/interfaces/cython/cantera/_utils.pyx index 4a402d0159..674a81271a 100644 --- a/interfaces/cython/cantera/_utils.pyx +++ b/interfaces/cython/cantera/_utils.pyx @@ -93,6 +93,23 @@ def use_legacy_rate_constants(pybool legacy): """ Cxx_use_legacy_rate_constants(legacy) +def hdf_support(): + """ + Returns list of libraries that include HDF support: + - 'h5py': HDF support by Python package 'h5py'. + - 'HighFive': if Cantera was compiled with C++ HighFive HDF support. + """ + out = [] + try: + pkg_resources.get_distribution("h5py") + except pkg_resources.DistributionNotFound: + pass + else: + out.append("h5py") + if CxxUsesHighFive(): + out.append("HighFive") + return set(out) + cdef Composition comp_map(X) except *: if isinstance(X, (str, bytes)): return parseCompString(stringify(X))