perf: use packaging.version instead of pkg_resources

This is the same functionality without a cost of loading a huge package.
This commit is contained in:
Alexander Schepanovski
2019-09-17 14:32:31 +07:00
parent 293a50d75c
commit eac0aa13b2
2 changed files with 4 additions and 3 deletions
+3 -3
View File
@@ -6,7 +6,7 @@ import time
import logging
import requests
import colorama
from pkg_resources import parse_version
from packaging import version
from dvc import __version__
from dvc.lock import Lock, LockError
@@ -28,7 +28,7 @@ class Updater(object): # pragma: no cover
self.lock = Lock(
self.updater_file + ".lock", tmp_dir=os.path.join(dvc_dir, "tmp")
)
self.current = parse_version(__version__).base_version
self.current = version.parse(__version__).base_version
def _is_outdated_file(self):
ctime = os.path.getmtime(self.updater_file)
@@ -95,7 +95,7 @@ class Updater(object): # pragma: no cover
json.dump(info, fobj)
def _is_outdated(self):
return parse_version(self.current) < parse_version(self.latest)
return version.parse(self.current) < version.parse(self.latest)
def _notify(self):
if not sys.stdout.isatty():
+1
View File
@@ -66,6 +66,7 @@ install_requires = [
"pathspec>=0.5.9",
"shortuuid>=0.5.0",
"tqdm>=4.35.0",
"packaging>=19.0",
"win-unicode-console>=0.5; sys_platform == 'win32'",
]