From 6b8aadd233ae2bbe31663873e51e2babaac89c6b Mon Sep 17 00:00:00 2001 From: Hanne Moa Date: Fri, 5 Jan 2024 12:33:45 +0100 Subject: [PATCH] Replace usage of pkg_resources.get_distribution --- python/nav/buildconf.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/python/nav/buildconf.py b/python/nav/buildconf.py index 16650c650c..c39aed4088 100644 --- a/python/nav/buildconf.py +++ b/python/nav/buildconf.py @@ -2,7 +2,12 @@ # pylint: disable=invalid-name import os import sysconfig -import pkg_resources + +try: + from importlib import metadata as _impmeta +except ImportError: + import importlib_metadata as _impmeta + datadir = os.path.join(sysconfig.get_config_var('datarootdir'), 'nav') localstatedir = os.path.join(datadir, 'var') @@ -10,9 +15,10 @@ djangotmpldir = os.path.join(datadir, "templates") docdir = os.path.join(datadir, "doc") + try: - VERSION = pkg_resources.get_distribution("nav").version -except pkg_resources.DistributionNotFound: + VERSION = _impmeta.version("nav") +except _impmeta.PackageNotFoundError: # If we're not installed, try to get the current version from Git tags import setuptools_scm