Switch from pkg_resources to importlib
One dependency less (at least für Python 3.8+) and it should be faster (not tested).
This commit is contained in:
parent
74ee50159d
commit
7615ee60d1
3 changed files with 12 additions and 6 deletions
|
@ -15,12 +15,16 @@ Comic modules for each comic are located in L{dosagelib.plugins}.
|
|||
"""
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
AppName = u'dosage'
|
||||
|
||||
from pkg_resources import get_distribution, DistributionNotFound
|
||||
try:
|
||||
version_info = get_distribution(AppName)
|
||||
__version__ = version_info.version # PEP 396
|
||||
except DistributionNotFound:
|
||||
from importlib.metadata import version, PackageNotFoundError
|
||||
except ImportError:
|
||||
from importlib_metadata import version, PackageNotFoundError
|
||||
|
||||
from .output import out
|
||||
|
||||
AppName = u'dosage'
|
||||
try:
|
||||
__version__ = version(AppName) # PEP 396
|
||||
except PackageNotFoundError:
|
||||
# package is not installed
|
||||
pass
|
||||
|
|
|
@ -5,3 +5,4 @@ six
|
|||
backports.shutil_get_terminal_size; python_version<'3.3'
|
||||
backports.functools_lru_cache; python_version<'3.2'
|
||||
cached_property; python_version<'3.8'
|
||||
importlib_metadata; python_version<'3.8'
|
||||
|
|
|
@ -41,6 +41,7 @@ install_requires =
|
|||
backports.shutil_get_terminal_size; python_version<'3.3'
|
||||
backports.functools_lru_cache; python_version<'3.2'
|
||||
cached_property; python_version<'3.8'
|
||||
importlib_metadata; python_version<'3.8'
|
||||
|
||||
[options.entry_points]
|
||||
console_scripts =
|
||||
|
|
Loading…
Reference in a new issue