diff --git a/Applications/Python/ogs.mesh/CMakeLists.txt b/Applications/Python/ogs.mesh/CMakeLists.txt index 5aa2e91c5540944cbefdfd372baa633628455902..4cdc635a427c001851ee54c3c4b5c009b3f69e40 100644 --- a/Applications/Python/ogs.mesh/CMakeLists.txt +++ b/Applications/Python/ogs.mesh/CMakeLists.txt @@ -1,8 +1,6 @@ # Create OpenGeoSys python module # https://pybind11.readthedocs.io/en/stable/compiling.html#building-with-cmake -pybind11_add_module( - mesh MODULE ogs_mesh_python_module.cpp OGSMesh.cpp -) +pybind11_add_module(mesh MODULE ogs_mesh_python_module.cpp OGSMesh.cpp) # lld linker strips out PyInit_OpenGeoSys symbol. Use standard linker. get_target_property(_link_options mesh LINK_OPTIONS) @@ -14,7 +12,6 @@ endif() target_link_libraries( mesh PRIVATE MeshLib BaseLib CMakeInfoLib GitInfoLib tclap ) -target_include_directories(mesh PRIVATE ../../../MeshLib) # Install into Python module root dir (enables 'import ogs.simulator') install(TARGETS mesh LIBRARY DESTINATION ogs) diff --git a/Applications/Python/ogs.mesh/OGSMesh.h b/Applications/Python/ogs.mesh/OGSMesh.h index 4b8326efa30b94781b244bb28d116fdbe006aa84..965f7c02dfe4db1b0225eea451108d2320a11af5 100644 --- a/Applications/Python/ogs.mesh/OGSMesh.h +++ b/Applications/Python/ogs.mesh/OGSMesh.h @@ -29,7 +29,9 @@ #include "MeshLib/Mesh.h" #include "MeshLib/Node.h" -class OGSMesh +// Needs to be exported, see +// https://pybind11.readthedocs.io/en/stable/advanced/misc.html#partitioning-code-over-multiple-extension-modules +class PYBIND11_EXPORT OGSMesh { public: explicit OGSMesh(MeshLib::Mesh* mesh); diff --git a/Applications/Python/ogs.simulator/CMakeLists.txt b/Applications/Python/ogs.simulator/CMakeLists.txt index 61d9ef51b8513b75840187b6ae91bab80c272dba..daf04fcd5e2867b54a536b20dcbbd7137dc8f4a6 100644 --- a/Applications/Python/ogs.simulator/CMakeLists.txt +++ b/Applications/Python/ogs.simulator/CMakeLists.txt @@ -15,7 +15,7 @@ endif() target_link_libraries( simulator PRIVATE ApplicationsLib BaseLib CMakeInfoLib GitInfoLib tclap ) -target_include_directories(simulator PRIVATE ../../CLI ../ogs.mesh) +target_include_directories(simulator PRIVATE ../../CLI) # Install into Python module root dir (enables 'import ogs.simulator') install(TARGETS simulator LIBRARY DESTINATION ogs) diff --git a/Applications/Python/ogs.simulator/ogs_python_module.cpp b/Applications/Python/ogs.simulator/ogs_python_module.cpp index c6ce2ac2ddf3e06ee46d0c99d776772928790411..d99fe1661841b1e25d53bcb7db5638e180c494d2 100644 --- a/Applications/Python/ogs.simulator/ogs_python_module.cpp +++ b/Applications/Python/ogs.simulator/ogs_python_module.cpp @@ -182,7 +182,12 @@ void finalize() BaseLib::unsetProjectDirectory(); } -/// python module name is OpenGeoSys +/// To use this module import dependencies first: +/// import ogs.mesh as mesh +/// import ogs.simulator as sim +/// +/// See also +/// https://github.com/pybind/pybind11/issues/1391#issuecomment-912642979 PYBIND11_MODULE(simulator, m) { m.attr("__name__") = "ogs.simulator";