Skip to content

Commit

Permalink
chore: Use importlib-metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
last-partizan committed May 15, 2022
1 parent 289055f commit 04e4ae3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
6 changes: 3 additions & 3 deletions docs/modeltranslation/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../..')))

try:
import modeltranslation
from importlib.metadata import version
# The version info for the project you're documenting, acts as replacement
# for |version| and |release|, also used in various other places throughout
# the built documents.

#
# The full PEP386-compliant version number version, including
# normalized alpha/beta/rc/dev tags (e.g. '0.5a1').
release = modeltranslation.__version__
release = version("django-modeltranslation")

# The short X.Y version (e.g.'0.5').
version = '.'.join(i for i in release.split('.')[:2])
Expand Down
4 changes: 0 additions & 4 deletions modeltranslation/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
from pathlib import Path

try:
from django import VERSION as _django_version

if _django_version < (3, 2):
default_app_config = 'modeltranslation.apps.ModeltranslationConfig'
except ImportError:
pass

__version__ = (Path(__file__).parent.parent / "VERSION").read_text().strip()
3 changes: 2 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = django-modeltranslation
version = attr:modeltranslation.__version__
version = file:VERSION
description = Translates Django models using a registration approach.
long_description = file:README.rst
long_description_content_type = text/x-rst
Expand All @@ -25,6 +25,7 @@ license = New BSD
install_requires =
Django>=2.2
six
importlib-metadata; python_version<"3.8"
packages =
modeltranslation
modeltranslation.management
Expand Down

0 comments on commit 04e4ae3

Please sign in to comment.