Unvendor distutils.version (#271)

* Unvendor distutils.version.

* Document breaking change.

* Update comment, add StrictVersion.
This commit is contained in:
Felix Fontein
2022-07-02 15:06:58 +02:00
committed by GitHub
parent 0071b343f1
commit 21d112bddb
5 changed files with 17 additions and 396 deletions
+11 -5
View File
@@ -9,9 +9,15 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type
# Once we drop support for Ansible 2.9, ansible-base 2.10, and ansible-core 2.11, we can
# remove the _version.py file, and replace the following import by
#
# from ansible.module_utils.compat.version import LooseVersion
# Once we drop support for ansible-core 2.11, we can remove the try/except.
from ._version import LooseVersion
from ansible.module_utils.six import raise_from
try:
from ansible.module_utils.compat.version import LooseVersion, StrictVersion
except ImportError:
try:
from distutils.version import LooseVersion, StrictVersion
except ImportError as exc:
msg = 'To use this plugin or module with ansible-core 2.11, you need to use Python < 3.12 with distutils.version present'
raise_from(ImportError(msg), exc)