mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
Merge pull request #5904 from borysiasty/pyQgisVersion
Make QGIS 2.99 compatible with 3.0 plugins by introducing PyQGIS API version
This commit is contained in:
commit
cef2db9ae3
@ -4,7 +4,7 @@ description=MetaSearch is a QGIS plugin to interact with metadata catalog servic
|
||||
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.
|
||||
category=Web
|
||||
version=0.3.5
|
||||
qgisMinimumVersion=2.14
|
||||
qgisMinimumVersion=3.0
|
||||
icon=images/MetaSearch.svg
|
||||
author=Tom Kralidis
|
||||
email=tomkralidis@gmail.com
|
||||
|
@ -3,7 +3,7 @@ name=DB Manager
|
||||
description=Manage your databases within Qgis
|
||||
category=Database
|
||||
version=0.1.20
|
||||
qgisMinimumVersion=2.0
|
||||
qgisMinimumVersion=3.0
|
||||
|
||||
author=Giuseppe Sucameli
|
||||
email=brush.tyler@gmail.com
|
||||
|
@ -4,7 +4,7 @@ description=Spatial data processing framework for QGIS
|
||||
about=Spatial data processing framework for QGIS
|
||||
category=Analysis
|
||||
version=2.12.99
|
||||
qgisMinimumVersion=2.13
|
||||
qgisMinimumVersion=3.0
|
||||
|
||||
author=Victor Olaya
|
||||
email=volayaf@gmail.com
|
||||
|
@ -32,6 +32,7 @@ from qgis.core import QgsSettings
|
||||
import sys
|
||||
import os
|
||||
import codecs
|
||||
import re
|
||||
try:
|
||||
import configparser
|
||||
except ImportError:
|
||||
@ -41,10 +42,10 @@ try:
|
||||
except ImportError:
|
||||
from imp import reload
|
||||
import qgis.utils
|
||||
from qgis.core import Qgis, QgsNetworkAccessManager, QgsApplication
|
||||
from qgis.core import QgsNetworkAccessManager, QgsApplication
|
||||
from qgis.gui import QgsMessageBar
|
||||
from qgis.utils import iface, plugin_paths
|
||||
from .version_compare import compareVersions, normalizeVersion, isCompatible
|
||||
from .version_compare import pyQgisVersion, compareVersions, normalizeVersion, isCompatible
|
||||
|
||||
|
||||
"""
|
||||
@ -212,12 +213,8 @@ class Repositories(QObject):
|
||||
# ----------------------------------------- #
|
||||
def urlParams(self):
|
||||
""" return GET parameters to be added to every request """
|
||||
# v = str(Qgis.QGIS_VERSION_INT)
|
||||
# TODO: make this proper again after 3.0 release, by uncommenting
|
||||
# the line below and removing the other return line:
|
||||
# return "?qgis=%d.%d" % (int(v[0]), int(v[1:3]))
|
||||
# TODO: Do the same for lines 469-472
|
||||
return "?qgis=3.0"
|
||||
# Strip down the point release segment from the version string
|
||||
return "?qgis=%s" % re.sub('\.\d*$', '', pyQgisVersion())
|
||||
|
||||
# ----------------------------------------- #
|
||||
def setRepositoryData(self, reposName, key, value):
|
||||
@ -466,10 +463,7 @@ class Repositories(QObject):
|
||||
qgisMaximumVersion = qgisMinimumVersion[0] + ".99"
|
||||
# if compatible, add the plugin to the list
|
||||
if not pluginNodes.item(i).firstChildElement("disabled").text().strip().upper() in ["TRUE", "YES"]:
|
||||
# TODO: make this proper again after 3.0 release, by uncommenting the line below and removing the next line
|
||||
# TODO: Do the same for lines 215-220
|
||||
# if isCompatible(Qgis.QGIS_VERSION, qgisMinimumVersion, qgisMaximumVersion):
|
||||
if isCompatible("3.0", qgisMinimumVersion, qgisMaximumVersion):
|
||||
if isCompatible(pyQgisVersion(), qgisMinimumVersion, qgisMaximumVersion):
|
||||
# add the plugin to the cache
|
||||
plugins.addFromRepository(plugin)
|
||||
self.mRepositories[reposName]["state"] = 2
|
||||
@ -618,7 +612,7 @@ class Plugins(QObject):
|
||||
if not qgisMaximumVersion:
|
||||
qgisMaximumVersion = qgisMinimumVersion[0] + ".99"
|
||||
# if compatible, add the plugin to the list
|
||||
if not isCompatible(Qgis.QGIS_VERSION, qgisMinimumVersion, qgisMaximumVersion):
|
||||
if not isCompatible(pyQgisVersion(), qgisMinimumVersion, qgisMaximumVersion):
|
||||
error = "incompatible"
|
||||
errorDetails = "%s - %s" % (qgisMinimumVersion, qgisMaximumVersion)
|
||||
elif not os.path.exists(metadataFile):
|
||||
|
@ -47,6 +47,7 @@ ALPHA, BETA, RC, PREVIEW and TRUNK which make the version number lower.
|
||||
"""
|
||||
from builtins import str
|
||||
from builtins import range
|
||||
from qgis.core import Qgis
|
||||
|
||||
import re
|
||||
|
||||
@ -199,3 +200,15 @@ def isCompatible(curVer, minVer, maxVer):
|
||||
curVer = "%04d%04d%04d" % (int(curVer[0]), int(curVer[1]), int(curVer[2]))
|
||||
|
||||
return (minVer <= curVer and maxVer >= curVer)
|
||||
|
||||
|
||||
def pyQgisVersion():
|
||||
""" Return current QGIS version number as X.Y.Z for testing plugin compatibility.
|
||||
If Y = 99, bump up to (X+1.0.0), so e.g. 2.99 becomes 3.0.0
|
||||
This way QGIS X.99 is only compatible with plugins for the upcoming major release.
|
||||
"""
|
||||
x, y, z = re.findall('^(\d*).(\d*).(\d*)', Qgis.QGIS_VERSION)[0]
|
||||
if y == '99':
|
||||
x = str(int(x) + 1)
|
||||
y = z = '0'
|
||||
return '%s.%s.%s' % (x, y, z)
|
||||
|
@ -253,6 +253,14 @@ bool QgsPluginRegistry::checkQgisVersion( const QString &minVersion, const QStri
|
||||
int qgisMinor = qgisVersionParts.at( 1 ).toInt();
|
||||
int qgisBugfix = qgisVersionParts.at( 2 ).toInt();
|
||||
|
||||
if ( qgisMinor == 99 )
|
||||
{
|
||||
// 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
|
||||
qgisMajor ++;
|
||||
qgisMinor = 0;
|
||||
qgisBugfix = 0;
|
||||
};
|
||||
|
||||
// build XxYyZz strings with trailing zeroes if needed
|
||||
QString minVer = QStringLiteral( "%1%2%3" ).arg( minVerMajor, 2, 10, QChar( '0' ) )
|
||||
.arg( minVerMinor, 2, 10, QChar( '0' ) )
|
||||
|
Loading…
x
Reference in New Issue
Block a user