Update utils.py to use 'packaging' instead of deprecated 'distutils'

PEP 632 deprecates the distutils module. The module is marked as deprecated in Python 3.10 and 3.11, and was eventually removed in Python 3.12.

The PEP advises to replace the usage of 'distutils.version' with 'packaging.version', with the 'LooseVersion' functionality being provided through the 'parse' method.

This replacement advice is detailed in the PEP under 'Migration Advice'
This commit is contained in:
leonsbane 2024-05-20 10:40:03 +00:00 committed by GitHub
commit 162592d286
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -10,7 +10,7 @@ import sys
import re
import unicodedata
from uuid import uuid4
from distutils.version import LooseVersion
from packaging.version import parse
from dateutil import tz, parser
from six import text_type, string_types, iteritems, ensure_text, ensure_binary
@ -112,8 +112,8 @@ def compare_version(a, b):
1 a is larger
0 equal
'''
a = LooseVersion(a)
b = LooseVersion(b)
a = parse(a)
b = parse(b)
if a < b:
return -1