Skip to content

Commit

Permalink
Move from pkg_resources to packaging, fix: #1925
Browse files Browse the repository at this point in the history
  • Loading branch information
hankcs committed Nov 17, 2024
1 parent 5008d7b commit fe47f5a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions hanlp/utils/io_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -688,15 +688,15 @@ 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


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):
Expand Down

0 comments on commit fe47f5a

Please sign in to comment.