chore: Use importlib-metadata

This commit is contained in:
Serg Tereshchenko 2022-05-15 09:16:49 +03:00
parent 289055fa57
commit 04e4ae36a7
3 changed files with 5 additions and 8 deletions

View file

@ -16,14 +16,14 @@ import sys
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])

View file

@ -1,5 +1,3 @@
from pathlib import Path
try:
from django import VERSION as _django_version
@ -7,5 +5,3 @@ try:
default_app_config = 'modeltranslation.apps.ModeltranslationConfig'
except ImportError:
pass
__version__ = (Path(__file__).parent.parent / "VERSION").read_text().strip()

View file

@ -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
@ -25,6 +25,7 @@ license = New BSD
install_requires =
Django>=2.2
six
importlib-metadata; python_version<"3.8"
packages =
modeltranslation
modeltranslation.management