generated from ansible-collections/collection_template
-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prepare for distutils.version being removed in Python 3.12
distutils has been deprecafed and will be removed from Python's stdlib in Python 3.12 (see python.org/dev/peps/pep-0632). This PR replaces the use of distutils.version.LooseVersion and distutils.version.StrictVersion with LooseVersion from the vendored copy of distutils.version included with ansible-core 2.12 (ansible/ansible#74644) if available, and falls back to distutils.version for ansible-core 2.11 and before. Since ansible-core 2.11 and earlier do not support Python 3.12 (since they use LooseVersion itself in various places), this incomplete fix should be OK for now. Also, the way this PR works (by adding a new module_utils version that abstracts away where LooseVersion comes from), it is easy to also fix this for ansible-core 2.11 and earlier later on. Signed-off-by: Abhijeet Kasurde <[email protected]>
- Loading branch information
Showing
5 changed files
with
25 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
bugfixes: | ||
- "Various modules and plugins - use vendored version of ``distutils.version`` included in ansible-core 2.12 if available. This avoids breakage when ``distutils`` is removed from the standard library of Python 3.12. Note that ansible-core 2.11, ansible-base 2.10 and Ansible 2.9 are right now not compatible with Python 3.12, hence this fix does not target these ansible-core/-base/2.9 versions." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
# Copyright: (c) 2021, Felix Fontein <[email protected]> | ||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) | ||
|
||
"""Provide Version object to compare version numbers.""" | ||
|
||
from __future__ import absolute_import, division, print_function | ||
__metaclass__ = type | ||
|
||
from ansible.module_utils.six import raise_from | ||
|
||
try: | ||
from ansible.module_utils.compat.version import LooseVersion | ||
except ImportError: | ||
try: | ||
from distutils.version import LooseVersion | ||
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters