28 #ifndef TOMOPY_COMMON_H 29 #define TOMOPY_COMMON_H 34 #include <pybind11/pybind11.h> 36 namespace py = pybind11;
40 # ifdef _tomographer_cxx_EXPORTS 41 # define TOMOGRAPHER_EXPORT __declspec(dllexport) 43 # define TOMOGRAPHER_EXPORT __declspec(dllimport) 46 # define TOMOGRAPHER_EXPORT __attribute__((visibility("default"))) 51 #ifndef TOMOGRAPHERPY_DEBUG_EIGEN_ASSERT_CAUSES_ABORT 52 # define TOMOGRAPHER_EIGEN_ASSERT_EXCEPTION 57 #pragma GCC visibility push(default) 58 #include <pybind11/eigen.h> 61 # error "TomographerPy requires enabled Eigen assertions, otherwise `TomographerCxxError` won't be raised as documented." 65 #pragma GCC visibility pop 67 #include <tomographer/tomographer_version.h> 71 #include <tomographerpy/pylogger.h> 76 #include <boost/version.hpp> 77 #if BOOST_VERSION >= 105600 78 #include <boost/core/demangle.hpp> 80 #include <boost/units/detail/utility.hpp> 81 namespace boost {
namespace core {
using boost::units::detail::demangle; } }
99 typedef Eigen::Matrix<std::complex<RealType>, Eigen::Dynamic, Eigen::Dynamic>
CplxMatrixType;
119 auto tomographer_module = py::module::import(
"tomographer");
120 if (PyErr_Occurred() != NULL) {
121 throw py::error_already_set();
124 tomographer_module.attr(
"__version__").cast<
std::string>();
125 if (module_tomographer_version != TOMOGRAPHER_VERSION) {
127 "Error: Version of compiled tomographer python module ("+module_tomographer_version +
128 ") does not match version used to compile the current module (" +
std::string(TOMOGRAPHER_VERSION)
129 +
"). If you updated tomographer, please recompile all dependent modules." 136 const std::string module_tomographer_pybind11_ver =
137 tomographer_module.attr(
"version").attr(
"compile_info").attr(
"get")(
"pybind11",
"").cast<std::string>();
138 if (module_tomographer_pybind11_ver != this_pybind11_ver) {
140 "Error: Compiled tomographer's version of PyBind11 (" + module_tomographer_pybind11_ver +
141 ") does not match version used to compile the current module (" + this_pybind11_ver
142 +
"). Please recompile all modules using the same PyBind11 version." 145 return tomographer_module;
int CountIntType
Integer type for template arguments (int)
double RealType
Real type for template arguments (double)
Some C++ utilities, with a tad of C++11 tricks.
Define tools for Eigen's eigen_assert() to throw an exception instead of assert'ing.
C++ Classes and Utilities for Python Modules.
py::module import_tomographer()
Import tomographer definitions into other Python modules.
Utilities for logging messages.