diff --git a/Applications/Python/ogs.callbacks/ogs_callbacks_module.cpp b/Applications/Python/ogs.callbacks/ogs_callbacks_module.cpp index c2e0789138ca9a4c86713cfe4a53685c5d287158..45b1bfedbeff89c42d4f02bc4adfb1abd3923f06 100644 --- a/Applications/Python/ogs.callbacks/ogs_callbacks_module.cpp +++ b/Applications/Python/ogs.callbacks/ogs_callbacks_module.cpp @@ -8,9 +8,11 @@ * */ -#include <algorithm> +#include <pybind11/eval.h> #include <pybind11/pybind11.h> +#include <algorithm> + #include "ProcessLib/BoundaryConditionAndSourceTerm/Python/BHEInflowPythonBoundaryConditionModule.h" #include "ProcessLib/BoundaryConditionAndSourceTerm/Python/PythonBoundaryConditionModule.h" #include "ProcessLib/BoundaryConditionAndSourceTerm/Python/PythonSourceTermModule.h" @@ -21,4 +23,12 @@ PYBIND11_MODULE(callbacks, m) ProcessLib::pythonBindBoundaryCondition(m); ProcessLib::bheInflowpythonBindBoundaryCondition(m); ProcessLib::SourceTerms::Python::pythonBindSourceTerm(m); + + pybind11::exec(R"( + try: + import OpenGeoSys + raise ImportError("The Python interpreter seems to be running inside the OGS binary, but you are about to import a Python module from OGS's Python bindings. Please do not import ogs.callbacks, but use the OpenGeoSys module, instead.") + except ModuleNotFoundError: + pass + )"); }