Philipp Hörist pushed to branch master at gajim / gajim
Commits: cc5ed8e2 by André Apitzsch at 2020-05-16T12:30:34+02:00 Use PEP-440 compatible version comparison
https://www.python.org/dev/peps/pep-0440/
- - - - - d63a796a by André Apitzsch at 2020-05-16T12:30:34+02:00 Optparser: Support PEP-440 versions
- - - - - 62ecb9ca by André Apitzsch at 2020-05-16T12:30:34+02:00 PluginManager: Use packaging's Version() directly
- - - - - fe82e887 by André Apitzsch at 2020-05-16T12:57:00+02:00 Optparser: Remove unneeded comparison
`new_version` passed to `update_config()` corresponds to the currently running version of Gajim, i.e. it's the latest version compared to the other versions mentioned in `update_config()`, that's why the conditions `V('...') <= new_version` are always true and can be removed.
- - - - -
6 changed files:
- flatpak/org.gajim.Gajim.yaml - gajim/common/helpers.py - gajim/common/optparser.py - gajim/gajim.py - gajim/plugins/pluginmanager.py - setup.cfg
Changes:
===================================== flatpak/org.gajim.Gajim.yaml ===================================== @@ -49,6 +49,24 @@ cleanup: - '*.la'
modules: + - name: python3-pyparsing + buildsystem: simple + build-commands: + - pip3 install --prefix=/app pyparsing-2.4.7-py2.py3-none-any.whl + sources: + - type: file + url: https://files.pythonhosted.org/packages/8a/bb/488841f56197b13700afd5658fc279... + sha256: ef9d7589ef3c200abe66653d3f1ab1033c3c419ae9b9bdb1240a85b024efc88b + + - name: python3-packaging + buildsystem: simple + build-commands: + - pip3 install --prefix=/app packaging-20.3-py2.py3-none-any.whl + sources: + - type: file + url: https://files.pythonhosted.org/packages/62/0a/34641d2bf5c917c96db0ded85ae4da... + sha256: 82f77b9bee21c1bafbf35a84905d604d5d1223801d639cf3ed140bd651c08752 + - name: python3-pycparser buildsystem: simple build-commands:
===================================== gajim/common/helpers.py ===================================== @@ -56,9 +56,9 @@ import urllib from urllib.parse import unquote from io import StringIO from datetime import datetime, timedelta -from distutils.version import LooseVersion as V from encodings.punycode import punycode_encode from functools import wraps +from packaging.version import Version as V
from nbxmpp.namespaces import Namespace from nbxmpp.const import Role
===================================== gajim/common/optparser.py ===================================== @@ -28,6 +28,7 @@ import sys import re import logging from pathlib import Path +from packaging.version import Version as V
from gi.repository import Gdk from nbxmpp.util import text_to_color @@ -126,32 +127,25 @@ class OptionsParser: return True
def update_config(self, old_version, new_version): - old_version_list = old_version.split('.') # convert '0.x.y' to (0, x, y) - old = [] - while old_version_list: - old.append(int(old_version_list.pop(0))) - new_version_list = new_version.split('.') - new = [] - while new_version_list: - new.append(int(new_version_list.pop(0))) - - if old < [0, 16, 4, 1] and new >= [0, 16, 4, 1]: + old = V(old_version) + + if old < V('0.16.4.1'): self.update_config_to_01641() - if old < [0, 16, 10, 1] and new >= [0, 16, 10, 1]: + if old < V('0.16.10.1'): self.update_config_to_016101() - if old < [0, 16, 10, 2] and new >= [0, 16, 10, 2]: + if old < V('0.16.10.2'): self.update_config_to_016102() - if old < [0, 16, 10, 4] and new >= [0, 16, 10, 4]: + if old < V('0.16.10.4'): self.update_config_to_016104() - if old < [0, 16, 10, 5] and new >= [0, 16, 10, 5]: + if old < V('0.16.10.5'): self.update_config_to_016105() - if old < [0, 98, 3] and new >= [0, 98, 3]: + if old < V('0.98.3'): self.update_config_to_0983() - if old < [1, 1, 93] and new >= [1, 1, 93]: + if old < V('1.1.93'): self.update_config_to_1193() - if old < [1, 1, 94] and new >= [1, 1, 94]: + if old < V('1.1.94'): self.update_config_to_1194() - if old < [1, 1, 95] and new >= [1, 1, 95]: + if old < V('1.1.95'): self.update_config_to_1195()
app.config.set('version', new_version)
===================================== gajim/gajim.py ===================================== @@ -22,7 +22,7 @@ import signal import platform from ctypes import CDLL, byref, create_string_buffer from ctypes.util import find_library -from distutils.version import LooseVersion as V +from packaging.version import Version as V
from gajim.common import i18n
===================================== gajim/plugins/pluginmanager.py ===================================== @@ -29,7 +29,7 @@ import fnmatch import zipfile from shutil import rmtree, move import configparser -from pkg_resources import parse_version +from packaging.version import Version as V
import gajim from gajim.common import app @@ -645,14 +645,14 @@ class PluginManager(metaclass=Singleton): continue
gajim_v = gajim.__version__.split('+', 1)[0] - gajim_v_cmp = parse_version(gajim_v) + gajim_v_cmp = V(gajim_v)
- if min_v and gajim_v_cmp < parse_version(min_v): + if min_v and gajim_v_cmp < V(min_v): log.warning('Plugin %s not loaded, newer version of' 'gajim required: %s < %s', elem_name, gajim_v, min_v) continue - if max_v and gajim_v_cmp > parse_version(max_v): + if max_v and gajim_v_cmp > V(max_v): log.warning('Plugin %s not loaded, plugin incompatible ' 'with current version of gajim: ' '%s > %s', elem_name, gajim_v, max_v)
===================================== setup.cfg ===================================== @@ -23,6 +23,7 @@ install_requires = css-parser keyring nbxmpp>=0.9.94 + packaging precis-i18n>=1.0.0 pyOpenSSL>=16.2 pycairo>=1.16.0
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/compare/59f0403f553655c4de9ba3e764019efb...