-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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 #3936
Prepare for distutils.version being removed in Python 3.12 #3936
Conversation
cc @Ajpantuso @Akasurde @AnderEnder @JayKayy @JoergFiedler @Lunik @MacLemon @NickatEpic @None @Nosmoht @Shaps @Thulium-Drake @UnderGreen @abulimov @alxgu @andytom @barryib @bcoca @claco @clc-runner @cmprescott @commel @dagwieers @danieljaouen @dcermak @dch @dj-wasabi @drcapulet @eest @enriclluelles @ericzolf @evrardjp @fxfitz @helldorado @ilijamt @indrajitr @jasperla @joshainglis @jpmens @justchris1 @karmab @kyleabenson @lrupp @lukasbestle @m-yosefpor @makaimc @martinm82 @marwatk @mekanix @metanovii @mheap @oolongbrothers @opoplawski @overhacked @paytroff @pilou- @quidame @rainerleber @saranyasridharan @scodeman @sealor @sh0shin @shinuza @sm4rk0 @tbielawa @tleguern @toabctl @tuxillo @waheedi @willthames @zanssa |
CCing the remaining maintainers: @mheap @oolongbrothers @opoplawski @overhacked @paytroff @pilou- @quidame @rainerleber @saranyasridharan @scodeman @sealor @sh0shin @shinuza @sm4rk0 @tbielawa @tleguern @toabctl @tuxillo @waheedi @willthames @zanssa |
Backport to stable-3: 💔 cherry-picking failed — conflicts found❌ Failed to cleanly apply a2f72be on top of patchback/backports/stable-3/a2f72be6c8d36c0b836755093e2837518b2e5869/pr-3936 Backporting merged PR #3936 into main
🤖 @patchback |
Backport to stable-4: 💚 backport PR created✅ Backport PR branch: Backported as #3941 🤖 @patchback |
* Prepare for distutils.version being removed in Python 2.12. * Fix copy'n'paste error. * Re-add Loose prefix. * Fix Python version typos. * Improve formulation. * Move message into own line. * Fix casing, now that the object is no longer called Version. (cherry picked from commit a2f72be)
@briantist @Andersson007 @zanssa thanks a lot for reviewing this! |
…ollections#3936) * Prepare for distutils.version being removed in Python 2.12. * Fix copy'n'paste error. * Re-add Loose prefix. * Fix Python version typos. * Improve formulation. * Move message into own line. * Fix casing, now that the object is no longer called Version. (cherry picked from commit a2f72be)
Manual backport to stable-3 in #3942. |
…3941) * Prepare for distutils.version being removed in Python 2.12. * Fix copy'n'paste error. * Re-add Loose prefix. * Fix Python version typos. * Improve formulation. * Move message into own line. * Fix casing, now that the object is no longer called Version. (cherry picked from commit a2f72be) Co-authored-by: Felix Fontein <[email protected]>
@felixfontein may I asked for community.zabbix: do I understand correctly. We may use the builtin class which falls back to distutils in older releases. But we might get problems in some unsupported version combinations? And do I interpreted this correctly that this class will only be in the community.general collection and not in the core Ansible? |
Yes. Right now the only unsupported comination (to my knowledge) is Python >= 3.12 with ansible-core < 2.12.
Yes. But you can copy it into your collection as well. If you only use |
Thx. We have now done it like this too. |
According to ansible-collections/community.docker#267, this change breaks the modules which use it on Ansible < 2.9.20 and ansible-base < 2.10.8 since it relies on ansible/ansible#73832. |
#3979 adds some documentation on this. |
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
COMPONENT NAME
Various modules and plugins