Skip to content

Commit 610f356

Browse files
author
wonder
committed
[FEATURE] support for custom plugin directories using QGIS_PLUGINPATH environment variables.
More paths can be passed, separated by semicolon. Patch from Chris Crook (#2608), slightly modified. git-svn-id: http://svn.osgeo.org/qgis/trunk@13236 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent a022e55 commit 610f356

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

python/utils.py

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,24 +71,31 @@ def initInterface(pointer):
7171

7272
def findPlugins(path):
7373
plugins = []
74-
for plugin in glob.glob(path + "/plugins/*"):
75-
if os.path.isdir(plugin):
74+
for plugin in glob.glob(path + "/*"):
75+
if os.path.isdir(plugin) and os.path.exists(os.path.join(plugin, '__init__.py')):
7676
plugins.append( os.path.basename(plugin) )
77-
7877
return plugins
7978

8079
def updateAvailablePlugins():
8180
from qgis.core import QgsApplication
82-
pythonPath = unicode(QgsApplication.pkgDataPath()) + "/python"
83-
homePythonPath = unicode(QgsApplication.qgisSettingsDirPath()) + "/python"
84-
85-
plugins = findPlugins( pythonPath )
86-
homePlugins = findPlugins( homePythonPath )
81+
plugindirs = [
82+
unicode(QgsApplication.pkgDataPath()) + "/python/plugins",
83+
unicode(QgsApplication.qgisSettingsDirPath()) + "/python/plugins"
84+
]
85+
env = os.environ.get("QGIS_PLUGINPATH")
86+
if env:
87+
plugindirs.extend(env.split(";"))
8788

8889
# merge the lists
89-
for p in homePlugins:
90-
if p not in plugins:
91-
plugins.append(p)
90+
plugins = []
91+
for pluginpath in plugindirs:
92+
newplugins = findPlugins(pluginpath)
93+
if len(newplugins) > 0:
94+
if pluginpath not in sys.path:
95+
sys.path.append(pluginpath)
96+
for p in newplugins:
97+
if p not in plugins:
98+
plugins.append(p)
9299

93100
global available_plugins
94101
available_plugins = plugins

0 commit comments

Comments
 (0)