Skip to content

Commit 38f89fc

Browse files
author
wonder
committed
Python plugins are now expected in (qgis-data-path)/python/plugins
git-svn-id: http://svn.osgeo.org/qgis/trunk@6519 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent fb7b670 commit 38f89fc

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

src/app/qgspythonutils.cpp

+5-11
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ void QgsPythonUtils::initPython(QgisInterface* interface)
4545
runString("import sys");
4646

4747
// expect that bindings are installed locally, so add the path to modules
48-
QString pythonPath = QgsApplication::pkgDataPath() + "/python";
49-
runString("sys.path.insert(0, \"" + pythonPath + "\")");
48+
// also add path to plugins
49+
runString("sys.path = [\"" + pythonPath() + "\", \"" + pluginsPath() + "\"] + sys.path");
5050

5151
// import SIP
5252
if (!runString("from sip import wrapinstance, unwrapinstance"))
@@ -104,8 +104,6 @@ void QgsPythonUtils::initPython(QgisInterface* interface)
104104
runString("iface = wrapinstance(" + QString::number((unsigned long) interface) + ", QgisInterface)");
105105
runString("plugins = {}");
106106

107-
setPluginsPath(QgsApplication::pluginPath() + "/python");
108-
109107
}
110108

111109
void QgsPythonUtils::exitPython()
@@ -206,18 +204,14 @@ QString QgsPythonUtils::getResult()
206204
}
207205

208206

209-
210-
void QgsPythonUtils::setPluginsPath(QString path)
207+
QString QgsPythonUtils::pythonPath()
211208
{
212-
mPluginsPath = path;
213-
214-
// alter sys.path to search for packages & modules in (plugin_dir)/python
215-
runString("sys.path.insert(0, '" + path + "')");
209+
return QgsApplication::pkgDataPath() + "/python";
216210
}
217211

218212
QString QgsPythonUtils::pluginsPath()
219213
{
220-
return mPluginsPath;
214+
return pythonPath() + "/plugins";
221215
}
222216

223217
QString QgsPythonUtils::getPluginMetadata(QString pluginName, QString function)

src/app/qgspythonutils.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ class QgsPythonUtils
4747
//! returns true if python support is ready to use (must be inited first)
4848
static bool isEnabled();
4949

50+
//! returns path where QGIS python stuff is located
51+
static QString pythonPath();
52+
5053
//! run a statement (wrapper for PyRun_String)
5154
//! this command is more advanced as enables error checking etc.
5255
//! @return true if no error occured
@@ -71,9 +74,6 @@ class QgsPythonUtils
7174

7275
/* plugins related functions */
7376

74-
//! change path
75-
static void setPluginsPath(QString path);
76-
7777
//! return current path for python plugins
7878
static QString pluginsPath();
7979

0 commit comments

Comments
 (0)