Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare for distutils.version being removed in Python 3.12 #258

Merged
merged 8 commits into from
Dec 24, 2021

Conversation

felixfontein
Copy link
Collaborator

@felixfontein felixfontein commented Dec 22, 2021

SUMMARY

distutils has been deprecafed and will be removed from Python's stdlib in Python 3.12 (see https://www.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.

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

Various modules and plugins

@felixfontein felixfontein changed the title Prepare for distutils.version being removed in Python 2.12 Prepare for distutils.version being removed in Python 3.12 Dec 23, 2021
changelogs/fragments/258-distutils.version.yml Outdated Show resolved Hide resolved
plugins/module_utils/version.py Outdated Show resolved Hide resolved
@felixfontein felixfontein merged commit 4b235a2 into ansible-collections:main Dec 24, 2021
@patchback
Copy link

patchback bot commented Dec 24, 2021

Backport to stable-1: 💚 backport PR created

✅ Backport PR branch: patchback/backports/stable-1/4b235a260737de318fd95453c0146534b199f10f/pr-258

Backported as #260

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

@felixfontein felixfontein deleted the distutils.version branch December 24, 2021 10:28
patchback bot pushed a commit that referenced this pull request Dec 24, 2021
* Prepare for distutils.version being removed in Python 2.12.

* Fix copy'n'paste error.

* Fix import.

* Re-add Loose prefix.

* Fix Python version typo.

* Improve formulation.

* Move message into own line.

* Fix casing, now that the object is no longer called Version.

(cherry picked from commit 4b235a2)
@felixfontein
Copy link
Collaborator Author

@briantist thanks for reviewing this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants