Update pybind11 to version 2.2.0

- Replace PYBIND11_PLUGIN with PYBIND11_MODULE

- Fix warnings about symbol visibility by replacing
  'namespace pybind11' with 'namespace PYBIND11_NAMESPACE'

- Pybind sets the default visibility of its namespace to 'hidden'
  Thus, our export functions like  ExportCSG(py::module &m) also are
  hidden by default. To work around that define DLL_HEADER
  '__attribute__ ((visibility ("default")))
  on GNUC platforms.
This commit is contained in:
Matthias Hochsteger 2017-09-01 09:33:57 +02:00
parent 74c8fa5cf4
commit 1430b89e39
12 changed files with 21 additions and 32 deletions

@ -1 +1 @@
Subproject commit fe0cf8b73b8e068c205e062c779eb694b194d6b4 Subproject commit 2a5a5ec0a47c245fbf1bb1a8a90b4c3278e01693

View File

@ -619,10 +619,8 @@ DLL_HEADER void ExportCSG(py::module &m)
; ;
} }
PYBIND11_PLUGIN(libcsg) { PYBIND11_MODULE(libcsg, m) {
py::module m("csg", "pybind csg");
ExportCSG(m); ExportCSG(m);
return m.ptr();
} }
#endif #endif

View File

@ -527,10 +527,8 @@ DLL_HEADER void ExportCSGVis(py::module &m)
}); });
} }
PYBIND11_PLUGIN(libcsgvis) { PYBIND11_MODULE(libcsgvis, m) {
py::module m("csg", "pybind csg");
ExportCSGVis(m); ExportCSGVis(m);
return m.ptr();
} }
#endif #endif

View File

@ -6,7 +6,8 @@ namespace py = pybind11;
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
namespace pybind11 {
namespace PYBIND11_NAMESPACE {
template<typename T> template<typename T>
bool CheckCast( py::handle obj ) { bool CheckCast( py::handle obj ) {
try{ try{

View File

@ -265,10 +265,8 @@ DLL_HEADER void ExportGeom2d(py::module &m)
} }
PYBIND11_PLUGIN(libgeom2d) { PYBIND11_MODULE(libgeom2d, m) {
py::module m("geom2d", "pybind geom2d");
ExportGeom2d(m); ExportGeom2d(m);
return m.ptr();
} }
#endif #endif

View File

@ -21,7 +21,11 @@
#define DLL_HEADER __declspec(dllimport) #define DLL_HEADER __declspec(dllimport)
#endif #endif
#else #else
#define DLL_HEADER #if __GNUC__ >= 4
#define DLL_HEADER __attribute__ ((visibility ("default")))
#else
#define DLL_HEADER
#endif
#endif #endif

View File

@ -23,7 +23,11 @@
#define DLL_HEADER __declspec(dllimport) #define DLL_HEADER __declspec(dllimport)
#endif #endif
#else #else
#define DLL_HEADER #if __GNUC__ >= 4
#define DLL_HEADER __attribute__ ((visibility ("default")))
#else
#define DLL_HEADER
#endif
#endif #endif

View File

@ -816,10 +816,8 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m)
})); }));
} }
PYBIND11_PLUGIN(libmesh) { PYBIND11_MODULE(libmesh, m) {
py::module m("mesh", "pybind mesh");
ExportNetgenMeshing(m); ExportNetgenMeshing(m);
return m.ptr();
} }
#endif #endif

View File

@ -46,10 +46,8 @@ DLL_HEADER void ExportNgOCC(py::module &m)
; ;
} }
PYBIND11_PLUGIN(libNgOCC) { PYBIND11_MODULE(libNgOCC, m) {
py::module m("NgOCC", "pybind NgOCC");
ExportNgOCC(m); ExportNgOCC(m);
return m.ptr();
} }
#endif // OCCGEOMETRY #endif // OCCGEOMETRY

View File

@ -6,8 +6,6 @@
#ifdef WIN32 #ifdef WIN32
#define DLL_HEADER __declspec(dllexport) #define DLL_HEADER __declspec(dllexport)
#else
#define DLL_HEADER
#endif #endif
using namespace netgen; using namespace netgen;
@ -47,10 +45,8 @@ DLL_HEADER void ExportSTL(py::module & m)
; ;
} }
PYBIND11_PLUGIN(libstl) { PYBIND11_MODULE(libstl, m) {
py::module m("stl", "pybind stl");
ExportSTL(m); ExportSTL(m);
return m.ptr();
} }
#endif #endif

View File

@ -1218,8 +1218,6 @@ void VisualSceneSTLMeshing :: MouseDblClick (int px, int py)
#ifdef WIN32 #ifdef WIN32
#define DLL_HEADER __declspec(dllexport) #define DLL_HEADER __declspec(dllexport)
#else
#define DLL_HEADER
#endif #endif
#include <../general/ngpython.hpp> #include <../general/ngpython.hpp>
@ -1245,9 +1243,7 @@ DLL_HEADER void ExportSTLVis(py::module &m)
}); });
} }
PYBIND11_PLUGIN(libstlvis) { PYBIND11_MODULE(libstlvis, m) {
py::module m("stlvis", "pybind stl vis");
ExportSTLVis(m); ExportSTLVis(m);
return m.ptr();
} }
#endif #endif

View File

@ -21,9 +21,8 @@ void DLL_HEADER ExportSTLVis(py::module &m);
void DLL_HEADER ExportNgOCC(py::module &m); void DLL_HEADER ExportNgOCC(py::module &m);
#endif // OCCGEOMETRY #endif // OCCGEOMETRY
PYBIND11_PLUGIN(libngpy) PYBIND11_MODULE(libngpy, ngpy)
{ {
py::module ngpy("libngpy", "pybind netgen module");
py::module meshing = ngpy.def_submodule("_meshing", "pybind meshing module"); py::module meshing = ngpy.def_submodule("_meshing", "pybind meshing module");
ExportNetgenMeshing(meshing); ExportNetgenMeshing(meshing);
py::module csg = ngpy.def_submodule("_csg", "pybind csg module"); py::module csg = ngpy.def_submodule("_csg", "pybind csg module");
@ -44,7 +43,6 @@ PYBIND11_PLUGIN(libngpy)
py::module stlvis = ngpy.def_submodule("stlvis", "pybind stlvis module"); py::module stlvis = ngpy.def_submodule("stlvis", "pybind stlvis module");
ExportSTLVis(stlvis); ExportSTLVis(stlvis);
#endif // OPENGL #endif // OPENGL
return ngpy.ptr();
} }
// Force linking libnglib to libnetgenpy // Force linking libnglib to libnetgenpy