I am currently trying to create a C++ library with pybind11. My .cpp-file is a simple test and looks like this:
#include <pybind11/pybind11.h>
namespace py = pybind11;
std::string test()
{
return "Test successful!";
}
PYBIND11_MODULE(TreeGenModule, m)
{
m.def("test", &test);
}
Opening a Python interactive console I can import my compiled module and use the test-function.
However when importing the module from within a Blender-addon I'm trying to write, I can import the module itself but the interpreter cannot find any of the defined functions.
Any ideas why this error occurs?
EDIT:
Here's what happens if I navigate to the folder of my module and import the module using an interactive python session:
Python 3.7.9 (default, Nov 20 2020, 02:21:39)
[GCC 10.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import TreeGenModule
>>> TreeGenModule.test()
'Test successful!'
However, if I try the same import from within my module and invoke TreeGenModule.test()
:
AttributeError: module 'TBO_Tree_Gen.cpp_bin.TreeGenModule' has no attribute 'test'