36 #ifndef NEKTAR_LIBRARY_LIBUTILITIES_PYTHON_NEKPYCONFIG_HPP
37 #define NEKTAR_LIBRARY_LIBUTILITIES_PYTHON_NEKPYCONFIG_HPP
39 #include <boost/version.hpp>
46 #if BOOST_VERSION < 106300
50 #ifdef BOOST_HAS_NUMPY
52 #include <boost/python.hpp>
53 #include <boost/python/numpy.hpp>
56 namespace np = boost::python::numpy;
60 #include <boost/numpy.hpp>
61 #include <boost/python.hpp>
64 namespace np = boost::numpy;
68 #define SIZENAME(s) SIZE_##s
69 #define NEKPY_WRAP_ENUM(ENUMNAME, MAPNAME) \
71 py::enum_<ENUMNAME> tmp(#ENUMNAME); \
72 for (int a = 0; a < (int)SIZENAME(ENUMNAME); ++a) \
74 tmp.value(MAPNAME[a], (ENUMNAME)a); \
76 tmp.export_values(); \
78 #define NEKPY_WRAP_ENUM_STRING(ENUMNAME, MAPNAME) \
80 py::enum_<ENUMNAME> tmp(#ENUMNAME); \
81 for (int a = 0; a < (int)SIZENAME(ENUMNAME); ++a) \
83 tmp.value(MAPNAME[a].c_str(), (ENUMNAME)a); \
85 tmp.export_values(); \
87 #if PY_MAJOR_VERSION == 2
88 #define NEKPY_WRAP_ENUM_STRING_DOCS(ENUMNAME, MAPNAME, DOCSTRING) \
90 py::enum_<ENUMNAME> tmp(#ENUMNAME); \
91 for (int a = 0; a < (int)SIZENAME(ENUMNAME); ++a) \
93 tmp.value(MAPNAME[a].c_str(), (ENUMNAME)a); \
95 tmp.export_values(); \
96 PyTypeObject *pto = reinterpret_cast<PyTypeObject *>(tmp.ptr()); \
97 PyDict_SetItemString(pto->tp_dict, "__doc__", \
98 PyString_FromString(DOCSTRING)); \
101 #define NEKPY_WRAP_ENUM_STRING_DOCS(ENUMNAME, MAPNAME, DOCSTRING) \
103 py::enum_<ENUMNAME> tmp(#ENUMNAME); \
104 for (int a = 0; a < (int)SIZENAME(ENUMNAME); ++a) \
106 tmp.value(MAPNAME[a].c_str(), (ENUMNAME)a); \
108 tmp.export_values(); \
109 PyTypeObject *pto = reinterpret_cast<PyTypeObject *>(tmp.ptr()); \
110 PyDict_SetItemString(pto->tp_dict, "__doc__", \
111 PyUnicode_FromString(DOCSTRING)); \