diff --git a/neutron/conf/db/migration_cli.py b/neutron/conf/db/migration_cli.py index e28ad9a8b7e..73abd5941d6 100644 --- a/neutron/conf/db/migration_cli.py +++ b/neutron/conf/db/migration_cli.py @@ -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 = { - entrypoint.name: entrypoint - for entrypoint in entry_points(group=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) diff --git a/requirements.txt b/requirements.txt index 2fc62781c0c..96991315f05 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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