From 57c1dafa6fb6fa6e0d71f94f79da8ddf1992ee17 Mon Sep 17 00:00:00 2001 From: James Booth Date: Fri, 13 Jun 2014 20:37:59 +0100 Subject: [PATCH] Python plugins: add all site package paths to sys.path --- src/plugins/python_plugins.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/plugins/python_plugins.c b/src/plugins/python_plugins.c index 8b6cecb3..26bbf2a5 100644 --- a/src/plugins/python_plugins.c +++ b/src/plugins/python_plugins.c @@ -51,15 +51,26 @@ python_env_init(void) PyEval_InitThreads(); python_api_init(); GString *path = g_string_new(Py_GetPath()); + g_string_append(path, ":"); gchar *plugins_dir = plugins_get_dir(); g_string_append(path, plugins_dir); g_string_append(path, "/"); g_free(plugins_dir); - g_string_append(path, ":"); - g_string_append(path, PROF_PYTHON_SITE_PATH); + PySys_SetPath(path->str); g_string_free(path, TRUE); + + // add site packages paths + PyRun_SimpleString( + "import site\n" + "import sys\n" + "from distutils.sysconfig import get_python_lib\n" + "sys.path.append(get_python_lib())\n" + "for dir in site.getsitepackages():\n" + " sys.path.append(dir)\n" + ); + allow_python_threads(); }