On Wed, 2013-05-01 at 12:28 -0700, Todd Lyons wrote:

> Python has a very simple initialization procedure, that part works
> with no issues.  The show-stopper problem I have so far is that I'm
> giving it a script to import that is in exim's config directory
> instead of in the python search path.  From the shell, I can specify
> an additional subdirectory to look in when importing modules, but I
> couldn't find a simple function in the python api to make it add a
> path to the python module loader search paths.

I had this same problem once, and did this workaround:

#define PYTHON_DIR "..."

static const char pypath[] =
"import sys\n"
"sys.path.append(\"" PYTHON_DIR "\")\n";

...

        Py_Initialize();

        m = PyImport_AddModule("__main__");
        globals = PyModule_GetDict(m);

        res = PyRun_String(pypath, Py_file_input, globals, globals);
        if (!res) {
                PyErr_Print();
                return -1;
        } else
                Py_DECREF(res);

johannes


-- 
## List details at https://lists.exim.org/mailman/listinfo/exim-dev Exim 
details at http://www.exim.org/ ##

Reply via email to