From d4300dcd96651a969fa1bc948c4c74830e5ce772 Mon Sep 17 00:00:00 2001 From: Tomas Babej Date: Wed, 9 Sep 2020 00:13:55 -0400 Subject: [PATCH] util: Use tasklib.__version__ to determine module version Importing pkg_resources module is notoriously slow, see [1,2]. Tasklib module now provides __version__ attribute for an easy method of version checking. [1] https://github.com/pypa/setuptools/issues/510 [2] https://github.com/pypa/setuptools/issues/926 --- taskwiki/util.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/taskwiki/util.py b/taskwiki/util.py index e87af7bfa..eaab2bd5a 100644 --- a/taskwiki/util.py +++ b/taskwiki/util.py @@ -3,12 +3,13 @@ from distutils.version import LooseVersion import contextlib -import pkg_resources import os import random import sys import vim # pylint: disable=F0401 +import tasklib + from taskwiki.errors import TaskWikiException from taskwiki import regexp @@ -371,8 +372,8 @@ def enforce_dependencies(cache): TASKWARRIOR_VERSION = '2.4.0' # Check tasklib version - tasklib_module_info = pkg_resources.get_distribution('tasklib') - tasklib_installed_version = LooseVersion(tasklib_module_info.version) + tasklib_module_version = getattr(tasklib, '__version__', '2.2.0') + tasklib_installed_version = LooseVersion(tasklib_module_version) tasklib_required_version = LooseVersion(TASKLIB_VERSION) if tasklib_required_version > tasklib_installed_version: