From 1cfb74cf087d05080940d21d2af5d00c1c45fbde Mon Sep 17 00:00:00 2001 From: Jakub Kadlcik Date: Sat, 10 Aug 2024 18:40:03 +0200 Subject: [PATCH] cli, rpmbuild, common: replace deprecated pkg_resources with importlib.metadata Fix #2674 Fix #3349 --- cli/copr_cli/main.py | 4 ++-- common/copr_common/request.py | 4 ++-- rpmbuild/main.py | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cli/copr_cli/main.py b/cli/copr_cli/main.py index 1a070a5aa..61d00f747 100644 --- a/cli/copr_cli/main.py +++ b/cli/copr_cli/main.py @@ -12,9 +12,9 @@ import time import warnings from collections import defaultdict +from importlib.metadata import distribution import six -import pkg_resources import requests try: @@ -1065,7 +1065,7 @@ def setup_parser(): help="Path to an alternative configuration file") parser.add_argument("--version", action="version", - version="%(prog)s version " + pkg_resources.require('copr-cli')[0].version) + version="%(prog)s version " + distribution("copr-cli").version) subparsers = parser.add_subparsers(title="actions") diff --git a/common/copr_common/request.py b/common/copr_common/request.py index ed0cb3b73..3660a0014 100644 --- a/common/copr_common/request.py +++ b/common/copr_common/request.py @@ -4,7 +4,7 @@ import json import time -import pkg_resources +from importlib.metadata import distribution from requests import get, post, put, RequestException @@ -23,7 +23,7 @@ class SafeRequest: package_name = 'copr-common' user_agent = { 'name': package_name, - 'version': pkg_resources.require(package_name)[0].version + 'version': distribution(package_name).version, } def __init__(self, auth=None, log=None, try_indefinitely=False, timeout=2 * 60): diff --git a/rpmbuild/main.py b/rpmbuild/main.py index 91f2d1420..56b24781d 100755 --- a/rpmbuild/main.py +++ b/rpmbuild/main.py @@ -11,7 +11,7 @@ import shutil import pprint import shlex -import pkg_resources +from importlib.metadata import distribution from copr_common.request import SafeRequest, RequestError from copr_rpmbuild import providers @@ -26,7 +26,7 @@ log.addHandler(logging.StreamHandler(sys.stdout)) try: - VERSION = pkg_resources.require('copr-rpmbuild')[0].version + VERSION = distribution("copr-rpmbuild").version except pkg_resources.DistributionNotFound: VERSION = 'git'