From 7cdf620889d5fc523a4bd451810351dd8c6724a9 Mon Sep 17 00:00:00 2001 From: Dale Smith Date: Mon, 25 Nov 2024 12:06:03 +1300 Subject: [PATCH] Replace pkg_resources with importlib, remove debug docs. As of Python 3.8, importlib.metadata is the provisional replacement for pkg_resources which depended on setuptools. In python 3.10 this is no longer provisional and supersedes pkg_resources with the same functionality. Also remove rest_framework_swagger which provides the `/docs/` endpoint temporarily. The library is end of life and should be replaced with drf-yasg or similar. Ref: https://importlib-metadata.readthedocs.io/en/latest/migration.html Ref: https://docs.python.org/3/library/importlib.metadata.html Change-Id: I102e94c8172f6ea660814dd8fcd44ed8239b2e67 --- adjutant/api/urls.py | 8 -------- adjutant/startup/loading.py | 4 ++-- requirements.txt | 1 + 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/adjutant/api/urls.py b/adjutant/api/urls.py index feb00b0..d80e747 100644 --- a/adjutant/api/urls.py +++ b/adjutant/api/urls.py @@ -13,9 +13,6 @@ # under the License. from django.urls import include, re_path -from django.conf import settings - -from rest_framework_swagger.views import get_swagger_view from adjutant.api import views from adjutant.api.views import build_version_details @@ -29,8 +26,3 @@ urlpatterns = [ build_version_details("1.0", "CURRENT", relative_endpoint="v1/") urlpatterns.append(re_path(r"^v1/?$", views_v1.V1VersionEndpoint.as_view())) urlpatterns.append(re_path(r"^v1/", include("adjutant.api.v1.urls"))) - - -if settings.DEBUG: - schema_view = get_swagger_view(title="Adjutant API") - urlpatterns.append(re_path(r"^docs/", schema_view)) diff --git a/adjutant/startup/loading.py b/adjutant/startup/loading.py index 0e603e9..36c3a33 100644 --- a/adjutant/startup/loading.py +++ b/adjutant/startup/loading.py @@ -12,10 +12,10 @@ # License for the specific language governing permissions and limitations # under the License. -import pkg_resources +import importlib_metadata as metadata def load_feature_sets(): - for entry_point in pkg_resources.iter_entry_points("adjutant.feature_sets"): + for entry_point in metadata.entry_points(group="adjutant.feature_sets"): feature_set = entry_point.load() feature_set().load() diff --git a/requirements.txt b/requirements.txt index 9463a94..926414f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -16,3 +16,4 @@ python-octaviaclient>=1.8.0 python-troveclient>=6.0.1 six>=1.12.0 confspirator>=0.2.2 +importlib-metadata>=6.2.1