From 72b31c0d7b3ad74978a164eb2e78ff358b189e6b Mon Sep 17 00:00:00 2001 From: yancong <32220263+ice-tong@users.noreply.github.com> Date: Tue, 27 Dec 2022 17:30:30 +0800 Subject: [PATCH] Deprecate distutils.version for removing warning info (#185) --- mim/click/compat.py | 4 ++-- mim/utils/utils.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mim/click/compat.py b/mim/click/compat.py index 7d00bff..9b7cf95 100644 --- a/mim/click/compat.py +++ b/mim/click/compat.py @@ -1,8 +1,8 @@ # Copyright (c) OpenMMLab. All rights reserved. -from distutils.version import LooseVersion from typing import Callable import click +from pip._vendor.packaging import version def autocompletion_to_shell_complete(autocompletion: Callable) -> Callable: @@ -44,7 +44,7 @@ def argument(*param_decls, **attrs): """ # 'autocompletion' will be removed in Click 8.1 and its new name is # 'shell_complete'. - if LooseVersion(click.__version__) >= LooseVersion('8.0.0'): + if version.parse(click.__version__) >= version.parse('8.0.0'): autocompletion = attrs.pop('autocompletion', None) if autocompletion is not None: attrs['shell_complete'] = autocompletion_to_shell_complete( diff --git a/mim/utils/utils.py b/mim/utils/utils.py index df69c46..69de178 100644 --- a/mim/utils/utils.py +++ b/mim/utils/utils.py @@ -10,13 +10,13 @@ import tarfile import typing from collections import defaultdict -from distutils.version import LooseVersion from email.parser import FeedParser from pkg_resources import get_distribution, parse_version from typing import Any, List, Optional, Tuple, Union import click import requests +from pip._vendor.packaging import version from requests.exceptions import InvalidURL, RequestException, Timeout from requests.models import Response @@ -285,7 +285,7 @@ def get_latest_version(package: str, timeout: int = 15) -> str: def is_version_equal(version1: str, version2: str) -> bool: - return LooseVersion(version1) == LooseVersion(version2) + return version.parse(version1) == version.parse(version2) @ensure_installation