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 subprocess
|
||||
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
|
||||
# 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')
|
||||
|
||||
|
||||
version_component_re = _lazy_re_compile(r'(\d+|[a-z]+|\.)')
|
||||
|
||||
|
||||
def get_version_tuple(version):
|
||||
"""
|
||||
Return a tuple of version numbers (e.g. (1, 2, 3)) from the version
|
||||
string (e.g. '1.2.3').
|
||||
"""
|
||||
loose_version = LooseVersion(version)
|
||||
version_numbers = []
|
||||
for item in loose_version.version:
|
||||
if not isinstance(item, int):
|
||||
for item in version_component_re.split(version):
|
||||
if item and item != '.':
|
||||
try:
|
||||
component = int(item)
|
||||
except ValueError:
|
||||
break
|
||||
version_numbers.append(item)
|
||||
else:
|
||||
version_numbers.append(component)
|
||||
return tuple(version_numbers)
|
||||
|
|
Loading…
Reference in New Issue