Merge "Get rid of pkg_resources"
This commit is contained in:
commit
0ac6cbec75
@ -10,16 +10,21 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import sys
|
||||||
|
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
import pkg_resources
|
|
||||||
|
|
||||||
from neutron._i18n import _
|
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 = 'neutron.db.alembic_migrations'
|
||||||
migration_entrypoints = {
|
migration_entrypoints = {
|
||||||
entrypoint.name: entrypoint
|
entrypoint.name: entrypoint
|
||||||
for entrypoint in pkg_resources.iter_entry_points(MIGRATION_ENTRYPOINTS)
|
for entrypoint in entry_points(group=MIGRATION_ENTRYPOINTS)
|
||||||
}
|
}
|
||||||
|
|
||||||
INSTALLED_SUBPROJECTS = list(migration_entrypoints)
|
INSTALLED_SUBPROJECTS = list(migration_entrypoints)
|
||||||
|
@ -566,13 +566,13 @@ def _get_installed_entrypoint(subproject):
|
|||||||
def _get_subproject_script_location(subproject):
|
def _get_subproject_script_location(subproject):
|
||||||
'''Get the script location for the installed subproject.'''
|
'''Get the script location for the installed subproject.'''
|
||||||
entrypoint = _get_installed_entrypoint(subproject)
|
entrypoint = _get_installed_entrypoint(subproject)
|
||||||
return ':'.join([entrypoint.module_name, entrypoint.attrs[0]])
|
return ':'.join([entrypoint.module, entrypoint.attr])
|
||||||
|
|
||||||
|
|
||||||
def _get_subproject_base(subproject):
|
def _get_subproject_base(subproject):
|
||||||
'''Get the import base name for the installed subproject.'''
|
'''Get the import base name for the installed subproject.'''
|
||||||
entrypoint = _get_installed_entrypoint(subproject)
|
entrypoint = _get_installed_entrypoint(subproject)
|
||||||
return entrypoint.module_name.split('.')[0]
|
return entrypoint.module.split('.')[0]
|
||||||
|
|
||||||
|
|
||||||
def get_alembic_version_table(config):
|
def get_alembic_version_table(config):
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import copy
|
import copy
|
||||||
|
import importlib.metadata
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
@ -28,7 +29,6 @@ import fixtures
|
|||||||
from neutron_lib import fixture as lib_fixtures
|
from neutron_lib import fixture as lib_fixtures
|
||||||
from neutron_lib.utils import helpers
|
from neutron_lib.utils import helpers
|
||||||
from oslo_utils import fileutils
|
from oslo_utils import fileutils
|
||||||
import pkg_resources
|
|
||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
from testtools import matchers
|
from testtools import matchers
|
||||||
|
|
||||||
@ -143,13 +143,13 @@ class TestCli(base.BaseTestCase):
|
|||||||
config = alembic_config.Config(ini)
|
config = alembic_config.Config(ini)
|
||||||
config.set_main_option('neutron_project', project)
|
config.set_main_option('neutron_project', project)
|
||||||
module_name = project.replace('-', '_') + '.db.migration'
|
module_name = project.replace('-', '_') + '.db.migration'
|
||||||
attrs = ('alembic_migrations',)
|
script_location = ':'.join([module_name, 'alembic_migrations'])
|
||||||
script_location = ':'.join([module_name, attrs[0]])
|
|
||||||
config.set_main_option('script_location', script_location)
|
config.set_main_option('script_location', script_location)
|
||||||
self.configs.append(config)
|
self.configs.append(config)
|
||||||
entrypoint = pkg_resources.EntryPoint(project,
|
entrypoint = importlib.metadata.EntryPoint(
|
||||||
module_name,
|
name=project,
|
||||||
attrs=attrs)
|
group='neutron.db.alembic_migrations',
|
||||||
|
value=script_location)
|
||||||
migration_cli.migration_entrypoints[project] = entrypoint
|
migration_cli.migration_entrypoints[project] = entrypoint
|
||||||
|
|
||||||
def _main_test_helper(self, argv, func_name, exp_kwargs=[{}]):
|
def _main_test_helper(self, argv, func_name, exp_kwargs=[{}]):
|
||||||
|
@ -56,3 +56,6 @@ python-designateclient>=2.7.0 # Apache-2.0
|
|||||||
os-vif>=3.1.0 # Apache-2.0
|
os-vif>=3.1.0 # Apache-2.0
|
||||||
futurist>=1.2.0 # Apache-2.0
|
futurist>=1.2.0 # Apache-2.0
|
||||||
tooz>=1.58.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
|
||||||
|
Loading…
Reference in New Issue
Block a user