Skip to content
Permalink
Browse files

[Plugin installer] Make QGIS x.99 only compatible with plugins for th…

…e next major release. Introduce 'pyQgisVersion' that usually sticks to QGIS_VERSION, but bumps up to the next release for all the .99 versions
  • Loading branch information
borysiasty committed Dec 18, 2017
1 parent 7c01b7e commit b43386605fc298f23b2c1db93d528432655340ce
Showing with 20 additions and 13 deletions.
  1. +7 −13 python/pyplugin_installer/installer_data.py
  2. +13 −0 python/pyplugin_installer/version_compare.py
@@ -32,6 +32,7 @@
import sys
import os
import codecs
import re
try:
import configparser
except ImportError:
@@ -41,10 +42,10 @@
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 @@ def allUnavailable(self):
# ----------------------------------------- #
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 @@ def xmlDownloaded(self):
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 @@ def pluginMetadata(fct):
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 @@
"""
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)

0 comments on commit b433866

Please sign in to comment.
You can’t perform that action at this time.