Merge "use importlib.metadata to get keyring version"

This commit is contained in:
Zuul 2022-04-29 17:21:37 +00:00 committed by Gerrit Code Review
commit b79a10f0b5
3 changed files with 17 additions and 5 deletions

View File

@ -20,11 +20,18 @@
import logging import logging
import warnings import warnings
try:
# For Python 3.8 and later
import importlib.metadata as importlib_metadata
except ImportError:
# For everyone else
import importlib_metadata
from debtcollector import removals from debtcollector import removals
from debtcollector import renames from debtcollector import renames
from keystoneauth1 import adapter from keystoneauth1 import adapter
from oslo_serialization import jsonutils from oslo_serialization import jsonutils
import pkg_resources import packaging.version
import requests import requests
try: try:
@ -33,9 +40,10 @@ try:
# NOTE(sdague): The conditional keyring import needs to only # NOTE(sdague): The conditional keyring import needs to only
# trigger if it's a version of keyring that's supported in global # trigger if it's a version of keyring that's supported in global
# requirements. Update _min and _bad when that changes. # requirements. Update _min and _bad when that changes.
keyring_v = pkg_resources.parse_version( keyring_v = packaging.version.Version(
pkg_resources.get_distribution("keyring").version) importlib_metadata.version('keyring')
keyring_min = pkg_resources.parse_version('5.5.1') )
keyring_min = packaging.version.Version('5.5.1')
# This is a list of versions, e.g., pkg_resources.parse_version('3.3') # This is a list of versions, e.g., pkg_resources.parse_version('3.3')
keyring_bad = [] keyring_bad = []
@ -43,7 +51,7 @@ try:
import keyring import keyring
else: else:
keyring = None keyring = None
except (ImportError, pkg_resources.DistributionNotFound): except (ImportError, importlib_metadata.PackageNotFoundError):
keyring = None keyring = None
pickle = None pickle = None

View File

@ -16,6 +16,7 @@ future==0.16.0
gitdb==0.6.4 gitdb==0.6.4
GitPython==1.0.1 GitPython==1.0.1
idna==2.6 idna==2.6
importlib_metadata==1.7.0
iso8601==0.1.11 iso8601==0.1.11
jsonschema==2.6.0 jsonschema==2.6.0
keyring==5.5.1 keyring==5.5.1
@ -40,6 +41,7 @@ oslo.log==3.36.0
oslo.serialization==2.18.0 oslo.serialization==2.18.0
oslo.utils==3.33.0 oslo.utils==3.33.0
oslotest==3.2.0 oslotest==3.2.0
packaging==20.4
paramiko==2.0.0 paramiko==2.0.0
pbr==2.0.0 pbr==2.0.0
pep257==0.7.0 pep257==0.7.0

View File

@ -13,3 +13,5 @@ oslo.utils>=3.33.0 # Apache-2.0
requests>=2.14.2 # Apache-2.0 requests>=2.14.2 # Apache-2.0
six>=1.10.0 # MIT six>=1.10.0 # MIT
stevedore>=1.20.0 # Apache-2.0 stevedore>=1.20.0 # Apache-2.0
importlib_metadata>=1.7.0;python_version<'3.8' # Apache-2.0
packaging>=20.4 # BSD