| |
@@ -0,0 +1,55 @@
|
| |
+ From 6af10b8905061856d4654dbe380f1de6c5a0eb76 Mon Sep 17 00:00:00 2001
|
| |
+ From: Benjamin A. Beasley <code@musicinmybrain.net>
|
| |
+ Date: Wed, 28 Sep 2022 08:28:18 -0400
|
| |
+ Subject: [PATCH] Use importlib.metadata on Python 3.10+
|
| |
+
|
| |
+ Favor importlib.metadata.packages_distributions() over
|
| |
+ importlib_metadata.packages_distributions() where it is available, i.e.,
|
| |
+ on Python 3.10 and later.
|
| |
+
|
| |
+ Depend on PyPI importlib_metadata only on Python 3.9 and older:
|
| |
+ conditionalize the requirements.txt entry on Python version.
|
| |
+
|
| |
+ Change-Id: I624fc0059057de05bb2bacd9c1238cba71ebad2a
|
| |
+ ---
|
| |
+
|
| |
+ diff --git a/cliff/command.py b/cliff/command.py
|
| |
+ index f8e38ad..57665ed 100644
|
| |
+ --- a/cliff/command.py
|
| |
+ +++ b/cliff/command.py
|
| |
+ @@ -13,7 +13,12 @@
|
| |
+ import abc
|
| |
+ import inspect
|
| |
+
|
| |
+ -import importlib_metadata
|
| |
+ +try:
|
| |
+ + # Python 3.10 and newer
|
| |
+ + from importlib.metadata import packages_distributions
|
| |
+ +except ImportError:
|
| |
+ + # Python 3.9 and older
|
| |
+ + from importlib_metadata import packages_distributions
|
| |
+ from stevedore import extension
|
| |
+
|
| |
+ from cliff import _argparse
|
| |
+ @@ -34,8 +39,7 @@
|
| |
+ # There can be multiple distribution in the case of namespace packages
|
| |
+ # so we'll just grab the first one
|
| |
+ _dists_by_mods = {
|
| |
+ - k: v[0] for k, v in
|
| |
+ - importlib_metadata.packages_distributions().items()
|
| |
+ + k: v[0] for k, v in packages_distributions().items()
|
| |
+ }
|
| |
+ return _dists_by_mods
|
| |
+
|
| |
+ diff --git a/requirements.txt b/requirements.txt
|
| |
+ index 79ed14f..4715045 100644
|
| |
+ --- a/requirements.txt
|
| |
+ +++ b/requirements.txt
|
| |
+ @@ -1,6 +1,5 @@
|
| |
+ autopage>=0.4.0 # Apache 2.0
|
| |
+ -# TODO: Drop this when Python 3.10 is our minimum supported version
|
| |
+ -importlib_metadata>=4.4 # Apache-2.0
|
| |
+ +importlib_metadata>=4.4; python_version < '3.10' # Apache-2.0
|
| |
+ cmd2>=1.0.0 # MIT
|
| |
+ PrettyTable>=0.7.2 # BSD
|
| |
+ stevedore>=2.0.1 # Apache-2.0
|
| |
The dependency is simply dropped in favor of the standard library (for Python 3.10 and later).
Offered upstream: https://review.opendev.org/c/openstack/cliff/+/859579/1
This fixes FTBFS due to missing
importlib_metadata
in python-keystoneclient.