Refs #32074 -- Removed usage of Python's deprecated distutils.version package.
The distutils package was formally deprecated in Python 3.10 and will be removed in Python 3.12.
This commit is contained in:
parent
fc268c8648
commit
b8c9e9fae1
|
@ -3,7 +3,8 @@ import functools
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
from distutils.version import LooseVersion
|
|
||||||
|
from django.utils.regex_helper import _lazy_re_compile
|
||||||
|
|
||||||
# Private, stable API for detecting the Python version. PYXY means "Python X.Y
|
# Private, stable API for detecting the Python version. PYXY means "Python X.Y
|
||||||
# or later". So that third-party apps can use these values, each constant
|
# or later". So that third-party apps can use these values, each constant
|
||||||
|
@ -95,15 +96,21 @@ def get_git_changeset():
|
||||||
return timestamp.strftime('%Y%m%d%H%M%S')
|
return timestamp.strftime('%Y%m%d%H%M%S')
|
||||||
|
|
||||||
|
|
||||||
|
version_component_re = _lazy_re_compile(r'(\d+|[a-z]+|\.)')
|
||||||
|
|
||||||
|
|
||||||
def get_version_tuple(version):
|
def get_version_tuple(version):
|
||||||
"""
|
"""
|
||||||
Return a tuple of version numbers (e.g. (1, 2, 3)) from the version
|
Return a tuple of version numbers (e.g. (1, 2, 3)) from the version
|
||||||
string (e.g. '1.2.3').
|
string (e.g. '1.2.3').
|
||||||
"""
|
"""
|
||||||
loose_version = LooseVersion(version)
|
|
||||||
version_numbers = []
|
version_numbers = []
|
||||||
for item in loose_version.version:
|
for item in version_component_re.split(version):
|
||||||
if not isinstance(item, int):
|
if item and item != '.':
|
||||||
break
|
try:
|
||||||
version_numbers.append(item)
|
component = int(item)
|
||||||
|
except ValueError:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
version_numbers.append(component)
|
||||||
return tuple(version_numbers)
|
return tuple(version_numbers)
|
||||||
|
|
Loading…
Reference in New Issue