diff options
-rw-r--r-- | src/plugins/scripts/python/weechat-python.c | 24 | ||||
-rw-r--r-- | src/plugins/scripts/weechat-script.c | 1 | ||||
-rw-r--r-- | weechat/src/plugins/scripts/python/weechat-python.c | 24 | ||||
-rw-r--r-- | weechat/src/plugins/scripts/weechat-script.c | 1 |
4 files changed, 48 insertions, 2 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)); diff --git a/src/plugins/scripts/weechat-script.c b/src/plugins/scripts/weechat-script.c index 28a35048f..6ca3717ee 100644 --- a/src/plugins/scripts/weechat-script.c +++ b/src/plugins/scripts/weechat-script.c @@ -155,7 +155,6 @@ weechat_script_search_full_name (t_weechat_plugin *plugin, { length = strlen (dir_home) + strlen (filename) + 16; final_name = (char *) malloc (length); - plugin->print_server (plugin, "final=[%s]\n", final_name); if (final_name) { snprintf (final_name, length, "%s/%s", dir_home, filename); diff --git a/weechat/src/plugins/scripts/python/weechat-python.c b/weechat/src/plugins/scripts/python/weechat-python.c index bf55a5262..b4f35281e 100644 --- a/weechat/src/plugins/scripts/python/weechat-python.c +++ b/weechat/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)); diff --git a/weechat/src/plugins/scripts/weechat-script.c b/weechat/src/plugins/scripts/weechat-script.c index 28a35048f..6ca3717ee 100644 --- a/weechat/src/plugins/scripts/weechat-script.c +++ b/weechat/src/plugins/scripts/weechat-script.c @@ -155,7 +155,6 @@ weechat_script_search_full_name (t_weechat_plugin *plugin, { length = strlen (dir_home) + strlen (filename) + 16; final_name = (char *) malloc (length); - plugin->print_server (plugin, "final=[%s]\n", final_name); if (final_name) { snprintf (final_name, length, "%s/%s", dir_home, filename); |