diff --git a/gns3server/modules/base_vm.py b/gns3server/modules/base_vm.py
index b42930a5..fa3934ec 100644
--- a/gns3server/modules/base_vm.py
+++ b/gns3server/modules/base_vm.py
@@ -24,7 +24,7 @@ import tempfile
import psutil
import platform
-from pkg_resources import parse_version
+from gns3server.utils import parse_version
from ..utils.asyncio import wait_run_in_executor
from ..ubridge.hypervisor import Hypervisor
from .vm_error import VMError
diff --git a/gns3server/modules/docker/__init__.py b/gns3server/modules/docker/__init__.py
index 3442d3fa..be218441 100644
--- a/gns3server/modules/docker/__init__.py
+++ b/gns3server/modules/docker/__init__.py
@@ -24,7 +24,7 @@ import logging
import aiohttp
import urllib
import json
-from pkg_resources import parse_version
+from gns3server.utils import parse_version
log = logging.getLogger(__name__)
diff --git a/gns3server/modules/dynamips/__init__.py b/gns3server/modules/dynamips/__init__.py
index a1deb920..a85ebc46 100644
--- a/gns3server/modules/dynamips/__init__.py
+++ b/gns3server/modules/dynamips/__init__.py
@@ -34,7 +34,7 @@ log = logging.getLogger(__name__)
from gns3server.utils.interfaces import interfaces, is_interface_up
from gns3server.utils.asyncio import wait_run_in_executor
-from pkg_resources import parse_version
+from gns3server.utils import parse_version
from uuid import UUID, uuid4
from ..base_manager import BaseManager
from ..project_manager import ProjectManager
diff --git a/gns3server/modules/dynamips/nodes/ethernet_switch.py b/gns3server/modules/dynamips/nodes/ethernet_switch.py
index 71ab9f80..b6e96977 100644
--- a/gns3server/modules/dynamips/nodes/ethernet_switch.py
+++ b/gns3server/modules/dynamips/nodes/ethernet_switch.py
@@ -21,7 +21,7 @@ http://github.com/GNS3/dynamips/blob/master/README.hypervisor#L558
"""
import asyncio
-from pkg_resources import parse_version
+from gns3server.utils import parse_version
from .device import Device
from ..nios.nio_udp import NIOUDP
diff --git a/gns3server/modules/qemu/qemu_vm.py b/gns3server/modules/qemu/qemu_vm.py
index 1992c30f..0ae3629d 100644
--- a/gns3server/modules/qemu/qemu_vm.py
+++ b/gns3server/modules/qemu/qemu_vm.py
@@ -30,7 +30,7 @@ import asyncio
import socket
import gns3server
-from pkg_resources import parse_version
+from gns3server.utils import parse_version
from .qemu_error import QemuError
from ..adapters.ethernet_adapter import EthernetAdapter
from ..nios.nio_udp import NIOUDP
diff --git a/gns3server/modules/virtualbox/virtualbox_vm.py b/gns3server/modules/virtualbox/virtualbox_vm.py
index fbd69039..8caadca9 100644
--- a/gns3server/modules/virtualbox/virtualbox_vm.py
+++ b/gns3server/modules/virtualbox/virtualbox_vm.py
@@ -28,7 +28,7 @@ import json
import socket
import asyncio
-from pkg_resources import parse_version
+from gns3server.utils import parse_version
from gns3server.utils.telnet_server import TelnetServer
from gns3server.utils.asyncio import wait_for_file_creation, wait_for_named_pipe_creation
from .virtualbox_error import VirtualBoxError
diff --git a/gns3server/modules/vmware/__init__.py b/gns3server/modules/vmware/__init__.py
index 8825d853..c84a4ce3 100644
--- a/gns3server/modules/vmware/__init__.py
+++ b/gns3server/modules/vmware/__init__.py
@@ -31,7 +31,7 @@ import codecs
from collections import OrderedDict
from gns3server.utils.interfaces import interfaces
from gns3server.utils.asyncio import subprocess_check_output
-from pkg_resources import parse_version
+from gns3server.utils import parse_version
log = logging.getLogger(__name__)
diff --git a/gns3server/modules/vpcs/vpcs_vm.py b/gns3server/modules/vpcs/vpcs_vm.py
index 3e5bd3c0..054ed47e 100644
--- a/gns3server/modules/vpcs/vpcs_vm.py
+++ b/gns3server/modules/vpcs/vpcs_vm.py
@@ -31,7 +31,7 @@ import shutil
from ...utils.asyncio import wait_for_process_termination
from ...utils.asyncio import monitor_process
from ...utils.asyncio import subprocess_check_output
-from pkg_resources import parse_version
+from gns3server.utils import parse_version
from .vpcs_error import VPCSError
from ..adapters.ethernet_adapter import EthernetAdapter
from ..nios.nio_udp import NIOUDP
diff --git a/gns3server/ubridge/hypervisor.py b/gns3server/ubridge/hypervisor.py
index 7a01d110..929d06f6 100644
--- a/gns3server/ubridge/hypervisor.py
+++ b/gns3server/ubridge/hypervisor.py
@@ -25,7 +25,7 @@ import asyncio
import socket
import re
-from pkg_resources import parse_version
+from gns3server.utils import parse_version
from gns3server.utils.asyncio import wait_for_process_termination
from gns3server.utils.asyncio import subprocess_check_output
from .ubridge_hypervisor import UBridgeHypervisor
diff --git a/gns3server/utils/__init__.py b/gns3server/utils/__init__.py
index fb58158b..344a504a 100644
--- a/gns3server/utils/__init__.py
+++ b/gns3server/utils/__init__.py
@@ -16,6 +16,7 @@
# along with this program. If not, see .
+import re
import textwrap
import posixpath
@@ -44,3 +45,32 @@ def int_to_macaddress(integer):
Convert an integer to a macaddress
"""
return ":".join(textwrap.wrap("%012x" % (integer), width=2))
+
+
+def parse_version(version):
+ """
+ Return a comparable tuple from a version string.
+
+ Replace pkg_resources.parse_version which now display a warning when use for comparing version with tuple
+
+ :returns: Version string as comparable tuple
+ """
+
+ release_type_found = False
+ version_infos = re.split('(\.|[a-z]+)', version)
+ version = []
+ for info in version_infos:
+ if info == '.' or len(info) == 0:
+ continue
+ try:
+ info = int(info)
+ version.append(info)
+ except ValueError:
+ # We want rc to be at lower level than dev version
+ if info == 'rc':
+ info = 'c'
+ version.append(info)
+ release_type_found = True
+ if release_type_found is False:
+ version.append("final")
+ return tuple(version)
diff --git a/tests/modules/vpcs/test_vpcs_vm.py b/tests/modules/vpcs/test_vpcs_vm.py
index 41558516..ce7cf577 100644
--- a/tests/modules/vpcs/test_vpcs_vm.py
+++ b/tests/modules/vpcs/test_vpcs_vm.py
@@ -22,7 +22,7 @@ import os
import sys
from tests.utils import asyncio_patch
-from pkg_resources import parse_version
+from gns3server.utils import parse_version
from unittest.mock import patch, MagicMock
from gns3server.modules.vpcs.vpcs_vm import VPCSVM
diff --git a/tests/test_utils.py b/tests/test_utils.py
index 567bcccc..d227f110 100644
--- a/tests/test_utils.py
+++ b/tests/test_utils.py
@@ -16,7 +16,7 @@
# along with this program. If not, see .
-from gns3server.utils import force_unix_path, macaddress_to_int, int_to_macaddress
+from gns3server.utils import *
def test_force_unix_path():
@@ -31,3 +31,18 @@ def test_macaddress_to_int():
def test_int_to_macaddress():
assert int_to_macaddress(52228632586) == "00:0c:29:11:b0:0a"
+
+
+def test_parse_version():
+ assert parse_version('1') == (1, 'final')
+ assert parse_version('1.3') == (1, 3, 'final')
+ assert parse_version('1.3.dev3') == (1, 3, 'dev', 3)
+ assert parse_version('1.3a1') == (1, 3, 'a', 1)
+ assert parse_version('1.3rc1') == (1, 3, 'c', 1)
+
+ assert parse_version('1.2.3') > parse_version('1.2.2')
+ assert parse_version('1.3') > parse_version('1.2.2')
+ assert parse_version('1.3') > parse_version('1.3alpha1')
+ assert parse_version('1.3') > parse_version('1.3rc1')
+ assert parse_version('1.3rc1') > parse_version('1.3alpha3')
+ assert parse_version('1.3dev1') > parse_version('1.3rc1')