Drop usage of importlib_metadata

This is follow-up of b7fe561d09 and use
TypeError caused by the interface change as the key, instead of python
versions, which may work better for distributions with own feature
backports.

Change-Id: I84113cf1dc4de0481c9878a83e2dcd99a8fe69b9
This commit is contained in:
Takashi Kajinami 2024-10-05 02:56:50 +09:00
parent 0ac6cbec75
commit 969de2944a
2 changed files with 13 additions and 12 deletions

View File

@ -10,22 +10,26 @@
# License for the specific language governing permissions and limitations
# under the License.
import sys
from importlib.metadata import entry_points
from oslo_config import cfg
from neutron._i18n import _
if sys.version_info < (3, 10, 0):
from importlib_metadata import entry_points
else:
from importlib.metadata import entry_points
MIGRATION_ENTRYPOINTS = 'neutron.db.alembic_migrations'
migration_entrypoints = {
try:
migration_entrypoints = {
entrypoint.name: entrypoint
for entrypoint in entry_points(group=MIGRATION_ENTRYPOINTS)
}
}
except TypeError:
# For python < 3.10
migration_entrypoints = {
entrypoint.name: entrypoint
for entrypoint in entry_points()[MIGRATION_ENTRYPOINTS]
}
INSTALLED_SUBPROJECTS = list(migration_entrypoints)

View File

@ -56,6 +56,3 @@ python-designateclient>=2.7.0 # Apache-2.0
os-vif>=3.1.0 # Apache-2.0
futurist>=1.2.0 # Apache-2.0
tooz>=1.58.0 # Apache-2.0
# TODO(tkajinam): Remove importlib_metadata when python 3.9 support is dropped
importlib_metadata>=3.6;python_version<"3.10" # Apache-2.0