Skip to content

Commit accc532

Browse files
committed
Use importlib_metadata to retrieve version
This small dependency allows us to reduce latency when importing. It can be removed when we drop Python 3.7 support. See also: https://github.com/pypa/setuptools_scm/#retrieving-package-version-at-runtime
1 parent 759ed09 commit accc532

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

setup.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,4 @@ include_package_data = True
3434
python_requires = >=3.6,<4.0
3535
install_requires =
3636
Django>=2.2
37+
importlib_metadata

simple_menu/__init__.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
from pkg_resources import get_distribution, DistributionNotFound
1+
from importlib_metadata import PackageNotFoundError, version
2+
23
from .menu import Menu, MenuItem
34

45
try:
5-
__version__ = get_distribution("django-simple-menu").version
6-
except DistributionNotFound:
6+
__version__ = version("django-simple-menu")
7+
except PackageNotFoundError:
78
# package is not installed
89
__version__ = None
910

0 commit comments

Comments
 (0)