Use vendored version of distutils.version (#269)

* Use vendored version of distutils.version

* Correct fragment

* Update plugins/module_utils/version.py

Co-authored-by: Felix Fontein <felix@fontein.de>

Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit 9c575b4762)
This commit is contained in:
Andrew Klychkov 2022-01-07 16:59:19 +03:00
commit 6fda6ed48c
3 changed files with 349 additions and 11 deletions

View file

@ -8,14 +8,9 @@
from __future__ import absolute_import, division, print_function
__metaclass__ = type
from ansible.module_utils.six import raise_from
# 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
try:
from ansible.module_utils.compat.version import LooseVersion
except ImportError:
try:
from distutils.version import LooseVersion
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)
from ._version import LooseVersion