diff --git a/docs/docs/hooks.py b/docs/docs/hooks.py index b038738565..fc1f98e4a0 100644 --- a/docs/docs/hooks.py +++ b/docs/docs/hooks.py @@ -4,10 +4,10 @@ import json import os import re from datetime import datetime -from distutils.version import StrictVersion # type: ignore[import] from pathlib import Path import requests +from packaging.version import Version here = Path(__file__).parent @@ -57,7 +57,7 @@ def fetch_rtd_versions(): print('No RTD token found - skipping RTD version fetch') # Sort versions by version number - versions = sorted(versions, key=lambda x: StrictVersion(x['version']), reverse=True) + versions = sorted(versions, key=lambda x: Version(x['version']), reverse=True) # Add "latest" version first if not any(x['title'] == 'latest' for x in versions): diff --git a/src/backend/InvenTree/plugin/plugin.py b/src/backend/InvenTree/plugin/plugin.py index 1e9518cc99..0c031b1608 100644 --- a/src/backend/InvenTree/plugin/plugin.py +++ b/src/backend/InvenTree/plugin/plugin.py @@ -7,6 +7,7 @@ import warnings from datetime import datetime from importlib.metadata import PackageNotFoundError, metadata from pathlib import Path +from sysconfig import get_path from typing import Optional from django.conf import settings @@ -517,7 +518,6 @@ class InvenTreePlugin(VersionMixin, MixinBase, MetaBase): return InvenTree.helpers.pui_url(f'/settings/admin/plugin/{config.pk}/') return InvenTree.helpers.pui_url('/settings/admin/plugin/') - # region package info @mark_final def _get_package_commit(self): """Get last git commit for the plugin.""" @@ -527,10 +527,9 @@ class InvenTreePlugin(VersionMixin, MixinBase, MetaBase): @mark_final def is_editable(cls): """Returns if the current part is editable.""" - from distutils.sysconfig import get_python_lib - pkg_name = cls.__name__.split('.')[0] - dist_info = list(Path(get_python_lib()).glob(f'{pkg_name}-*.dist-info')) + py_lib = get_path('platlib') + dist_info = list(Path(py_lib).glob(f'{pkg_name}-*.dist-info')) return bool(len(dist_info) == 1) @classmethod