Skip to content
Snippets Groups Projects
Commit 004e29b5 authored by Lars Bilke's avatar Lars Bilke Committed by Tom Fischer
Browse files

[py] Fix and instructions on importating simulator modules.

parent b355bae6
No related branches found
No related tags found
No related merge requests found
# 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)
......@@ -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);
......
......@@ -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)
......@@ -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";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment