Skip to content

Commit fe47f5a

Browse files
committed
Move from pkg_resources to packaging, fix: #1925
1 parent 5008d7b commit fe47f5a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

hanlp/utils/io_util.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
from hanlp_downloader import Downloader
2727
from hanlp_downloader.log import DownloadCallback
28-
from pkg_resources import parse_version
28+
from packaging.version import Version
2929

3030
import hanlp
3131
from hanlp_common.constant import HANLP_URL, HANLP_VERBOSE
@@ -688,15 +688,15 @@ def check_outdated(package='hanlp', version=__version__, repository_url='https:/
688688
Returns:
689689
Parsed installed version and latest version.
690690
"""
691-
installed_version = parse_version(version)
691+
installed_version = Version(version)
692692
latest_version = get_latest_info_from_pypi(package, repository_url)
693693
return installed_version, latest_version
694694

695695

696696
def get_latest_info_from_pypi(package='hanlp', repository_url='https://pypi.python.org/pypi/%s/json'):
697697
url = repository_url % package
698698
response = urllib.request.urlopen(url).read()
699-
return parse_version(json.loads(response)['info']['version'])
699+
return Version(json.loads(response)['info']['version'])
700700

701701

702702
def check_version_conflicts(extras=None):

0 commit comments

Comments
 (0)