13 #include "gnc-module.h"
14 #include "gnc-module-api.h"
17 GNC_MODULE_API_DECL(libgncmod_python)
20 int libgncmod_python_gnc_module_system_interface = 0;
23 int libgncmod_python_gnc_module_current = 0;
24 int libgncmod_python_gnc_module_revision = 0;
25 int libgncmod_python_gnc_module_age = 0;
29 libgncmod_python_gnc_module_path(
void)
31 return g_strdup(
"gnucash/python");
35 libgncmod_python_gnc_module_description(
void)
37 return g_strdup(
"An embedded Python interpreter");
40 #if PY_VERSION_HEX >= 0x03000000
41 extern PyObject* PyInit__sw_app_utils(
void);
42 extern PyObject* PyInit__sw_core_utils(
void);
44 extern void init_sw_app_utils(
void);
45 extern void init_sw_core_utils(
void);
49 libgncmod_python_gnc_module_init(
int refcount)
55 gchar *pkgdatadir, *init_filename;
58 #if PY_VERSION_HEX >= 0x03000000
59 PyInit__sw_app_utils();
60 PyInit__sw_core_utils();
79 pkgdatadir = gnc_path_get_pkgdatadir();
80 init_filename = g_build_filename(pkgdatadir,
"python/init.py", (
char*)NULL);
81 g_debug(
"Looking for python init script at %s", (init_filename ? init_filename :
"<null>"));
82 fp = fopen(init_filename,
"r");
85 PyRun_SimpleFile(fp, init_filename);
92 g_warning(
"Unable to initialize Python module (unable to open %s)", init_filename);
94 g_free(init_filename);
101 libgncmod_python_gnc_module_end(
int refcount)