diff options
author | Emmanuel Bouthenot <kolter@openics.org> | 2006-10-29 01:38:54 +0000 |
---|---|---|
committer | Emmanuel Bouthenot <kolter@openics.org> | 2006-10-29 01:38:54 +0000 |
commit | b84f75eba6f7149ca398bfe71dad7695c9898f66 (patch) | |
tree | f08ad937109dac686c1c3f1c3400bf5dffdab5e3 /src/plugins/scripts/python | |
parent | 7772bcfd33cdc7ae600fcefe038a36d3787663d1 (diff) | |
download | weechat-b84f75eba6f7149ca398bfe71dad7695c9898f66.zip |
adding $weechat_dir/python in the top of sys.path
Diffstat (limited to 'src/plugins/scripts/python')
-rw-r--r-- | src/plugins/scripts/python/weechat-python.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/plugins/scripts/python/weechat-python.c b/src/plugins/scripts/python/weechat-python.c index bf55a5262..b4f35281e 100644 --- a/src/plugins/scripts/python/weechat-python.c +++ b/src/plugins/scripts/python/weechat-python.c @@ -1819,6 +1819,9 @@ weechat_python_load (t_weechat_plugin *plugin, char *filename) FILE *fp; PyThreadState *python_current_interpreter; PyObject *weechat_module, *weechat_outputs, *weechat_dict; + PyObject *python_path, *path; + char *w_home, *p_home; + int len; plugin->print_server (plugin, "Loading Python script \"%s\"", filename); @@ -1860,6 +1863,27 @@ weechat_python_load (t_weechat_plugin *plugin, char *filename) return 0; } + /* adding $weechat_dir/python in $PYTHONPATH */ + python_path = PySys_GetObject ("path"); + w_home = plugin->get_info (plugin, "weechat_dir", NULL); + if (w_home) + { + len = strlen (w_home) + 1 + strlen("python") + 1; + p_home = (char *) malloc (len * sizeof(char)); + if (p_home) + { + snprintf (p_home, len, "%s/python", w_home); + path = PyString_FromString (p_home); + if (path != NULL) + { + PyList_Insert (python_path, 0, path); + Py_DECREF (path); + } + free (p_home); + } + free (w_home); + } + /* define some constants */ weechat_dict = PyModule_GetDict(weechat_module); PyDict_SetItemString(weechat_dict, "PLUGIN_RC_OK", PyInt_FromLong((long) PLUGIN_RC_OK)); |