remove distutils

This commit is contained in:
Matthias Mair 2026-06-23 07:30:11 +02:00
parent 69b9d45b62
commit fb2cd9b411
No known key found for this signature in database
GPG Key ID: A593429DDA23B66A
2 changed files with 5 additions and 6 deletions

View File

@ -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):

View File

@ -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