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 #1165

Merged
merged 4 commits into from
Dec 29, 2021

Conversation

Akasurde
Copy link
Member

@Akasurde Akasurde commented Dec 23, 2021

SUMMARY

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

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

changelogs/fragments/disutils.version.yml
plugins/module_utils/version.py
plugins/modules/vmware_category.py
plugins/modules/vmware_vc_infraprofile_info.py

distutils has been deprecafed and will be removed from
Python's stdlib in Python 3.12 (see https://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 <akasurde@redhat.com>
@Akasurde
Copy link
Member Author

cc @felixfontein @Andersson007

plugins/module_utils/version.py Outdated Show resolved Hide resolved
Co-authored-by: Felix Fontein <felix@fontein.de>
Copy link
Collaborator

@mariolenz mariolenz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Akasurde ansible-tox-linters fais because plugins/module_utils/version.py imports distutils.version.LooseVersion but doesn't use it. Can you please have a look and fix this?

Copy link
Contributor

@felixfontein felixfontein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should shut the linter up:

plugins/module_utils/version.py Outdated Show resolved Hide resolved
plugins/module_utils/version.py Outdated Show resolved Hide resolved
mariolenz and others added 2 commits December 26, 2021 16:23
Co-authored-by: Felix Fontein <felix@fontein.de>
Co-authored-by: Felix Fontein <felix@fontein.de>
@mariolenz
Copy link
Collaborator

recheck

@mariolenz
Copy link
Collaborator

recheck

@Akasurde
Copy link
Member Author

recheck

@mariolenz
Copy link
Collaborator

@goneri Do you know why the last 4 CI jobs keep failing? I don't really understand this:

The task includes an option with an undefined variable. The error was: {'vcenter': "{{ hostvars['vcenter']['nodepool']['interface_ip']}}", 'esxi1': "{{ 'esxi1' in hostvars and hostvars['esxi1']['nodepool']['interface_ip']}}", 'esxi2': "{{ 'esxi2' in hostvars and hostvars['esxi2']['nodepool']['interface_ip']}}", 'datastore': "{{ hostvars[groups['controller'][0]]['nodepool']['interface_ip']}}"}: 'dict object' has no attribute 'controller'

The error appears to be in '/var/lib/zuul/builds/4e16d375128c4cadaf2953a15324aee2/untrusted/project_0/github.com/ansible/ansible-zuul-jobs/roles/vmware-ci-write-etc-hosts/tasks/main.yaml': line 16, column 3, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:


- name: Write the new /etc/hosts
  ^ here

@mariolenz
Copy link
Collaborator

This should shut the linter up

Thx @felixfontein, it looks like it did! We still have some checks that fail, but I think this is a CI issue and has nothing to do with this PR.

@mariolenz
Copy link
Collaborator

recheck

@mariolenz mariolenz closed this Dec 27, 2021
@mariolenz mariolenz reopened this Dec 27, 2021
Copy link
Collaborator

@mariolenz mariolenz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mariolenz
Copy link
Collaborator

recheck

@goneri
Copy link
Member

goneri commented Dec 27, 2021

@mariolenz I keep an eye on the CI jobs. For the record, you can ignore the softwarefactory jobs for now. It's still experimental at this stage.

@goneri
Copy link
Member

goneri commented Dec 27, 2021

hum, looks like there is several problems at the same time :-(. I will take a look when I'm back from PTO.

@mariolenz
Copy link
Collaborator

recheck

Copy link
Collaborator

@mariolenz mariolenz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mariolenz mariolenz added the gate label Dec 29, 2021
Copy link
Contributor

@ansible-zuul ansible-zuul bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@ansible-zuul ansible-zuul bot merged commit ca7901f into ansible-collections:main Dec 29, 2021
@mariolenz
Copy link
Collaborator

@goneri

hum, looks like there is several problems at the same time :-(. I will take a look when I'm back from PTO.

FYI: I've added the the gate label and this PR has been merged. But you should see the same problems in other PRs.

Enjoy your PTO!

@Akasurde Akasurde deleted the looseversion branch January 1, 2022 14:37
@felixfontein
Copy link
Contributor

Please consider creating a follow-up PR based on ansible-collections/community.general#3984.

@Akasurde
Copy link
Member Author

Akasurde commented Jan 6, 2022

cc @felixfontein #1177

softwarefactory-project-zuul bot pushed a commit that referenced this pull request May 4, 2022
Prepare for distutils.version being removed in Python 3.12

SUMMARY
This is a follow-up PR to #1165 and replaces the use of distutils.version.StrictVersion with ansible.module_utils.compat.version.StrictVersion.
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
plugins/module_utils/version.py
plugins/module_utils/vmware.py
ADDITIONAL INFORMATION
distutils has been deprecated and will be removed from
Python's stdlib in Python 3.12 (see PEP 632).
Also, see here and the following comments.
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.

5 participants