Skip to content

Commit cef2db9

Browse files
authoredJan 3, 2018
Merge pull request #5904 from borysiasty/pyQgisVersion
Make QGIS 2.99 compatible with 3.0 plugins by introducing PyQGIS API version
2 parents df547e1 + 51bb631 commit cef2db9

File tree

6 files changed

+31
-16
lines changed

6 files changed

+31
-16
lines changed
 

‎python/plugins/MetaSearch/metadata.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description=MetaSearch is a QGIS plugin to interact with metadata catalog servic
44
about=MetaSearch is a QGIS plugin to interact with metadata catalog services, supporting the OGC Catalog Service for the Web (CSW) standard. MetaSearch provides an easy and intuitive approach and user-friendly interface to searching metadata catalogs within QGIS.
55
category=Web
66
version=0.3.5
7-
qgisMinimumVersion=2.14
7+
qgisMinimumVersion=3.0
88
icon=images/MetaSearch.svg
99
author=Tom Kralidis
1010
email=tomkralidis@gmail.com

‎python/plugins/db_manager/metadata.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name=DB Manager
33
description=Manage your databases within Qgis
44
category=Database
55
version=0.1.20
6-
qgisMinimumVersion=2.0
6+
qgisMinimumVersion=3.0
77

88
author=Giuseppe Sucameli
99
email=brush.tyler@gmail.com

‎python/plugins/processing/metadata.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description=Spatial data processing framework for QGIS
44
about=Spatial data processing framework for QGIS
55
category=Analysis
66
version=2.12.99
7-
qgisMinimumVersion=2.13
7+
qgisMinimumVersion=3.0
88

99
author=Victor Olaya
1010
email=volayaf@gmail.com

‎python/pyplugin_installer/installer_data.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import sys
3333
import os
3434
import codecs
35+
import re
3536
try:
3637
import configparser
3738
except ImportError:
@@ -41,10 +42,10 @@
4142
except ImportError:
4243
from imp import reload
4344
import qgis.utils
44-
from qgis.core import Qgis, QgsNetworkAccessManager, QgsApplication
45+
from qgis.core import QgsNetworkAccessManager, QgsApplication
4546
from qgis.gui import QgsMessageBar
4647
from qgis.utils import iface, plugin_paths
47-
from .version_compare import compareVersions, normalizeVersion, isCompatible
48+
from .version_compare import pyQgisVersion, compareVersions, normalizeVersion, isCompatible
4849

4950

5051
"""
@@ -212,12 +213,8 @@ def allUnavailable(self):
212213
# ----------------------------------------- #
213214
def urlParams(self):
214215
""" return GET parameters to be added to every request """
215-
# v = str(Qgis.QGIS_VERSION_INT)
216-
# TODO: make this proper again after 3.0 release, by uncommenting
217-
# the line below and removing the other return line:
218-
# return "?qgis=%d.%d" % (int(v[0]), int(v[1:3]))
219-
# TODO: Do the same for lines 469-472
220-
return "?qgis=3.0"
216+
# Strip down the point release segment from the version string
217+
return "?qgis=%s" % re.sub('\.\d*$', '', pyQgisVersion())
221218

222219
# ----------------------------------------- #
223220
def setRepositoryData(self, reposName, key, value):
@@ -466,10 +463,7 @@ def xmlDownloaded(self):
466463
qgisMaximumVersion = qgisMinimumVersion[0] + ".99"
467464
# if compatible, add the plugin to the list
468465
if not pluginNodes.item(i).firstChildElement("disabled").text().strip().upper() in ["TRUE", "YES"]:
469-
# TODO: make this proper again after 3.0 release, by uncommenting the line below and removing the next line
470-
# TODO: Do the same for lines 215-220
471-
# if isCompatible(Qgis.QGIS_VERSION, qgisMinimumVersion, qgisMaximumVersion):
472-
if isCompatible("3.0", qgisMinimumVersion, qgisMaximumVersion):
466+
if isCompatible(pyQgisVersion(), qgisMinimumVersion, qgisMaximumVersion):
473467
# add the plugin to the cache
474468
plugins.addFromRepository(plugin)
475469
self.mRepositories[reposName]["state"] = 2
@@ -618,7 +612,7 @@ def pluginMetadata(fct):
618612
if not qgisMaximumVersion:
619613
qgisMaximumVersion = qgisMinimumVersion[0] + ".99"
620614
# if compatible, add the plugin to the list
621-
if not isCompatible(Qgis.QGIS_VERSION, qgisMinimumVersion, qgisMaximumVersion):
615+
if not isCompatible(pyQgisVersion(), qgisMinimumVersion, qgisMaximumVersion):
622616
error = "incompatible"
623617
errorDetails = "%s - %s" % (qgisMinimumVersion, qgisMaximumVersion)
624618
elif not os.path.exists(metadataFile):

‎python/pyplugin_installer/version_compare.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"""
4848
from builtins import str
4949
from builtins import range
50+
from qgis.core import Qgis
5051

5152
import re
5253

@@ -199,3 +200,15 @@ def isCompatible(curVer, minVer, maxVer):
199200
curVer = "%04d%04d%04d" % (int(curVer[0]), int(curVer[1]), int(curVer[2]))
200201

201202
return (minVer <= curVer and maxVer >= curVer)
203+
204+
205+
def pyQgisVersion():
206+
""" Return current QGIS version number as X.Y.Z for testing plugin compatibility.
207+
If Y = 99, bump up to (X+1.0.0), so e.g. 2.99 becomes 3.0.0
208+
This way QGIS X.99 is only compatible with plugins for the upcoming major release.
209+
"""
210+
x, y, z = re.findall('^(\d*).(\d*).(\d*)', Qgis.QGIS_VERSION)[0]
211+
if y == '99':
212+
x = str(int(x) + 1)
213+
y = z = '0'
214+
return '%s.%s.%s' % (x, y, z)

‎src/app/qgspluginregistry.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,14 @@ bool QgsPluginRegistry::checkQgisVersion( const QString &minVersion, const QStri
253253
int qgisMinor = qgisVersionParts.at( 1 ).toInt();
254254
int qgisBugfix = qgisVersionParts.at( 2 ).toInt();
255255

256+
if ( qgisMinor == 99 )
257+
{
258+
// we want the API version, so for x.99 bump it up to the next major release: e.g. 2.99 to 3.0.0
259+
qgisMajor ++;
260+
qgisMinor = 0;
261+
qgisBugfix = 0;
262+
};
263+
256264
// build XxYyZz strings with trailing zeroes if needed
257265
QString minVer = QStringLiteral( "%1%2%3" ).arg( minVerMajor, 2, 10, QChar( '0' ) )
258266
.arg( minVerMinor, 2, 10, QChar( '0' ) )

0 commit comments

Comments
 (0)
Please sign in to comment.