mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Bug 799138 - Port to new Python C config API
This commit is contained in:
parent
ed4921271c
commit
1d8c525afc
@ -65,15 +65,29 @@ libgncmod_python_gnc_module_description(void)
|
||||
int
|
||||
libgncmod_python_gnc_module_init(int refcount)
|
||||
{
|
||||
Py_Initialize();
|
||||
|
||||
#ifdef __WIN32
|
||||
wchar_t* argv = NULL;
|
||||
PySys_SetArgv(0, &argv);
|
||||
|
||||
#else
|
||||
char* argv = NULL;
|
||||
#endif
|
||||
PyStatus status;
|
||||
PyConfig config;
|
||||
PyConfig_InitPythonConfig(&config);
|
||||
status = PyConfig_SetBytesArgv(&config, 0, &argv);
|
||||
if (PyStatus_Exception(status))
|
||||
{
|
||||
PyConfig_Clear(&config);
|
||||
return FALSE;
|
||||
}
|
||||
Py_Initialize();
|
||||
gchar *pkgdatadir = gnc_path_get_pkgdatadir();
|
||||
gchar *init_filename = g_build_filename(pkgdatadir, "python/init.py", (char*)NULL);
|
||||
g_debug("Looking for python init script at %s", init_filename);
|
||||
#ifdef __WIN32
|
||||
FILE *fp = fopen(init_filename, "rb");
|
||||
#else
|
||||
FILE *fp = fopen(init_filename, "r");
|
||||
#endif
|
||||
if (fp)
|
||||
{
|
||||
PyRun_SimpleFile(fp, init_filename);
|
||||
@ -87,6 +101,7 @@ libgncmod_python_gnc_module_init(int refcount)
|
||||
}
|
||||
g_free(init_filename);
|
||||
g_free(pkgdatadir);
|
||||
PyConfig_Clear(&config);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user