1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Python plugins: add all site package paths to sys.path

This commit is contained in:
James Booth 2014-06-13 20:37:59 +01:00
parent d250400aec
commit 57c1dafa6f

View File

@ -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();
}