Skip to content

Commit

Permalink
cli, rpmbuild, common: replace deprecated pkg_resources with importli…
Browse files Browse the repository at this point in the history
…b.metadata

Fix fedora-copr#2674
Fix fedora-copr#3349
  • Loading branch information
FrostyX committed Aug 10, 2024
1 parent 19ff52e commit 1cfb74c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions cli/copr_cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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")

Expand Down
4 changes: 2 additions & 2 deletions common/copr_common/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import json
import time
import pkg_resources
from importlib.metadata import distribution
from requests import get, post, put, RequestException


Expand All @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions rpmbuild/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'

Expand Down

0 comments on commit 1cfb74c

Please sign in to comment.