Skip to content

Commit

Permalink
util: Use tasklib.__version__ to determine module version
Browse files Browse the repository at this point in the history
Importing pkg_resources module is notoriously slow, see [1,2]. Tasklib
module now provides __version__ attribute for an easy method of version
checking.

[1] pypa/setuptools#510
[2] pypa/setuptools#926
  • Loading branch information
tbabej committed Sep 18, 2020
1 parent 36ff81f commit d4300dc
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions taskwiki/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit d4300dc

Please sign in to comment.