From 7113a2fffe480e4dee11575ff824d056c7d1b1e7 Mon Sep 17 00:00:00 2001 From: Nour El Mawass Date: Fri, 10 Feb 2023 15:48:59 +0100 Subject: [PATCH] Replace `pkg_resources` with `importlib.metadata` --- fawltydeps/main.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/fawltydeps/main.py b/fawltydeps/main.py index 451822f1a..c2d18690a 100644 --- a/fawltydeps/main.py +++ b/fawltydeps/main.py @@ -9,8 +9,6 @@ from pathlib import Path from typing import List, Optional, Set, TextIO -import pkg_resources - from fawltydeps import extract_imports from fawltydeps.check import compare_imports_to_dependencies from fawltydeps.extract_declared_dependencies import extract_declared_dependencies @@ -23,6 +21,11 @@ UnusedDependency, ) +if sys.version_info >= (3, 8): + import importlib.metadata as importlib_metadata +else: + import importlib_metadata + logger = logging.getLogger(__name__) @@ -138,7 +141,7 @@ def main() -> int: "-V", "--version", action="version", - version=f"Fawltydeps {pkg_resources.get_distribution('fawltydeps').version}", + version=f"Fawltydeps {importlib_metadata.version('fawltydeps')}", help=("Print the version number of fawltydeps"), ) select_action.add_argument(