#ifndef WIN32
FILE *pyFile = fopen(fileName, "r");
PyRun_SimpleFile(pyFile, fileName);
#else
FILE *fp = fopen(fileName,"r");
fseek(fp,0,SEEK_END);
long len = ftell(fp);;
fseek(fp,0,SEEK_SET);
char *buf = new char[len];
fread(buf,len,1,fp);
fclose(fp);
PyRun_SimpleString(buf);
delete buf;
#endif
For informational purposes, heres my module that works fine in Linux:
static PyObject* openwars_SetTitle(PyObject *self, PyObject *title)
{
char *newTitle;
if (!PyArg_ParseTuple(title, "s:SetTitle", &newTitle))
return NULL;
BOOST_FOREACH(IScriptCallback it, GlobalPythonScript->onSetTitle)
(*it)(boost::any(newTitle));
Py_RETURN_NONE;
};
static PyMethodDef openwars_Methods[] = {
{"SetTitle", openwars_SetTitle, METH_VARARGS,
"Sets the title of the main window."},
{NULL, NULL, 0, NULL}
};
static PyModuleDef openwars_Module = {
PyModuleDef_HEAD_INIT, "openwars", NULL, -1, openwars_Methods,
NULL, NULL, NULL, NULL
};
I have placed a breakpoint in the method, and it is never hit.
Yes python has been initialized, and the logic to add my embedded module has been executed properly. Also, I downloaded python 3.2 and installed it from the website, and used the supplied library and header files straight from the installed directories.
Any ideas on what would cause this?