For the past few days I've been struggling importing a SWIG-generated module. I'm using Python 3.4.1 with SWIG 3.0.5.
I've setup my interface API.i file as follows:
%module Root
%{
#include "Root.h"
%}
%include "Root.h"
Nothing fancy in the header, as I'm just trying to get something going. A API_wrap.cxx
file is generated and so is a Root.py
file. So far so good.
Now, based on the following site: https://docs.python.org/2/faq/windows.html#how-can-i-embed-python-into-a-windows-application they imply that I can load the module directly (all in the same EXE, without the need to have a separate DLL) by doing the following:
Py_Initialize();
PyInit__Root();
PyRun_SimpleString("import Root");
The import works fine if I don't have a Root.py file still, but then I lose the shadow/proxy class (among other things, I'm guessing). If I do have the Root.py file, I get the following error:
"Import can't find module, or can't find name in module."
I notice if I write gibberish in the Root.py file, I get a syntax error, which makes it pretty evident that the generated Root.py is problematic. I imagine there's some sort of setup I've done wrong, but if anyone has any suggestions, they would be appreciated!