Skip to content
Snippets Groups Projects
Verified Commit 8f4dfd1a authored by Tamas Gal's avatar Tamas Gal :speech_balloon:
Browse files

Use importlib instead of the deprecated pkg_resources

parent 7677d6ba
Branches
No related tags found
No related merge requests found
Pipeline #44505 passed
...@@ -17,11 +17,14 @@ import sys ...@@ -17,11 +17,14 @@ import sys
import os import os
from datetime import date from datetime import date
import sphinx_rtd_theme import sphinx_rtd_theme
from pkg_resources import get_distribution try:
from importlib.metadata import version as get_version
version = get_version('{{cookiecutter.project_slug}}')
except ImportError:
from pkg_resources import get_distribution
version = get_distribution('{{cookiecutter.project_slug}}').version
# -- Project information ----------------------------------------------------- # -- Project information -----------------------------------------------------
version = get_distribution('{{cookiecutter.project_slug}}').version
short_version = '.'.join(version.split('.')[:2]) short_version = '.'.join(version.split('.')[:2])
project = '{{cookiecutter.project_slug}} {}'.format(short_version) project = '{{cookiecutter.project_slug}} {}'.format(short_version)
copyright = '{0}, {{cookiecutter.author}}'.format(date.today().year) copyright = '{0}, {{cookiecutter.author}}'.format(date.today().year)
......
from pkg_resources import get_distribution, DistributionNotFound try:
from importlib.metadata import version as get_version
version = get_distribution(__name__).version version = get_version(__name__)
except ImportError:
from pkg_resources import get_distribution
version = get_distribution(__name__).version
from .calc import Calculator from .calc import Calculator
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment