From fe47f5a0a4e245f4bb0353f1c0a752e19d705e30 Mon Sep 17 00:00:00 2001 From: hankcs Date: Sun, 17 Nov 2024 01:04:01 -0800 Subject: [PATCH] Move from `pkg_resources` to `packaging`, fix: https://github.com/hankcs/HanLP/issues/1925 --- hanlp/utils/io_util.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hanlp/utils/io_util.py b/hanlp/utils/io_util.py index ea87c671c..da0609f68 100644 --- a/hanlp/utils/io_util.py +++ b/hanlp/utils/io_util.py @@ -25,7 +25,7 @@ from hanlp_downloader import Downloader from hanlp_downloader.log import DownloadCallback -from pkg_resources import parse_version +from packaging.version import Version import hanlp from hanlp_common.constant import HANLP_URL, HANLP_VERBOSE @@ -688,7 +688,7 @@ def check_outdated(package='hanlp', version=__version__, repository_url='https:/ Returns: Parsed installed version and latest version. """ - installed_version = parse_version(version) + installed_version = Version(version) latest_version = get_latest_info_from_pypi(package, repository_url) return installed_version, latest_version @@ -696,7 +696,7 @@ def check_outdated(package='hanlp', version=__version__, repository_url='https:/ def get_latest_info_from_pypi(package='hanlp', repository_url='https://pypi.python.org/pypi/%s/json'): url = repository_url % package response = urllib.request.urlopen(url).read() - return parse_version(json.loads(response)['info']['version']) + return Version(json.loads(response)['info']['version']) def check_version_conflicts(extras=None):