Don't use deprecated distutils from python 3.10

distutils is deprecated in 3.10: https://peps.python.org/pep-0632/
Ansible requires it to be replaced[1]

[1] https://github.com/ansible-community/community-topics/issues/96
https://github.com/ansible-collections/news-for-maintainers/issues/18

Change-Id: I2bae37f206319e8f9ace468f5b94f6be643b6a3c
This commit is contained in:
Sagi Shnaidman 2022-07-27 13:50:03 +03:00 committed by Jakob Meng
parent 0215e2a5d4
commit ccbbc319ce
2 changed files with 20 additions and 2 deletions

View File

@ -29,7 +29,16 @@
import abc
import copy
from distutils.version import StrictVersion
from ansible.module_utils.six import raise_from
try:
from ansible.module_utils.compat.version import StrictVersion
except ImportError:
try:
from distutils.version import StrictVersion
except ImportError as exc:
raise_from(ImportError('To use this plugin or module with ansible-core'
' < 2.11, you need to use Python < 3.12 with '
'distutils.version present'), exc)
import importlib
import os

View File

@ -56,7 +56,16 @@ import collections
import os
import sys
import time
from distutils.version import StrictVersion
from ansible.module_utils.six import raise_from
try:
from ansible.module_utils.compat.version import StrictVersion
except ImportError:
try:
from distutils.version import StrictVersion
except ImportError as exc:
raise_from(ImportError('To use this plugin or module with ansible-core'
' < 2.11, you need to use Python < 3.12 with '
'distutils.version present'), exc)
from io import StringIO
import json