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

pkg_resources is deprecated #72

Open
p-try opened this issue Feb 23, 2024 · 6 comments · May be fixed by #71
Open

pkg_resources is deprecated #72

p-try opened this issue Feb 23, 2024 · 6 comments · May be fixed by #71

Comments

@p-try
Copy link

p-try commented Feb 23, 2024

Before actually creating a new issue
I confirm, I have read the FAQ (https://www.claudiokuenzler.com/blog/308/check-esxi-hardware-faq-frequently-asked-questions): Y
I confirm, I have restarted the CIM server (/etc/init.d/sfcbd-watchdog restart) on the ESXi server and the problem remains: Y
I confirm, I have cleared the server's local IPMI cache (localcli hardware ipmi sel clear) and restarted the services (/sbin/services.sh restart) on the ESXi server and the problem remains: Y

Describe the bug
The script uses the following code to check the version of pywbem:

# pywbem 0.7.0 handling is special, some patched 0.7.0 installations work differently
try:
  pywbemversion = pywbem.__version__
except:
  pywbemversion = pkg_resources.get_distribution("pywbem").version
else:
  pywbemversion = pywbem.__version__
verboseoutput("Found pywbem version "+pywbemversion)

A deprecation warning appears:
DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html

Expected behavior
Output should not contain the deprecation warning.

Versions:

  • check_esxi_hardware plugin: 20221230
  • VMware ESXi: 7.0u1
  • pywbem: 1.6.2
  • Python: 3.10.12
  • Third party tools (Dell OMSA, HP Offline Bundle, etc): none
@p-try p-try linked a pull request Feb 23, 2024 that will close this issue
p-try added a commit to p-try/check_esxi_hardware that referenced this issue Feb 23, 2024
@Napsty
Copy link
Owner

Napsty commented Feb 26, 2024

The PR is good, however it breaks backward compatibility with older systems, using an older Python version.
importlib.metadata (https://docs.python.org/3/library/importlib.metadata.html) was added in Python 3.8. Some users (unfortunately) still use older systems with an older Python version - mainly RHEL 7 which ships Python 2.7 and 3.6 by default.

RHEL 7 is EOL end of June this year. I guess we can in July make a new release of the check_esxi_hardware plugin and set new requirements. EOL systems would no longer be supported and need to use an older version of the plugin.

So let's keep this in "backlog" and look at this again later this year when the last "big" OS releases stop supporting very old Python versions.

In the meantime, as a workaround, you could ignore the deprecation warnings: https://stackoverflow.com/questions/879173/how-to-ignore-deprecation-warnings-in-python

@emlowe
Copy link

emlowe commented Oct 4, 2024

Ping about this - RHEL 7 and python 3.7 (and earlier) are out of support now (Oct 2024)

@Napsty
Copy link
Owner

Napsty commented Oct 22, 2024

Thanks for the reminder. Yes, it's time now. I will work on this soon.

@Napsty
Copy link
Owner

Napsty commented Oct 25, 2024

Alright there are a couple of things to consider:

  • The use of pkg_resources is deprecated in favor of importlib.resources, as stated in https://setuptools.pypa.io/en/latest/pkg_resources.html.
  • However importlib was only added in Python 3.7. There are active LTS Linux versions around, which still ship with Python 3.6 (EL 8). This means using importlib could lead to other unwanted dependency problems and for the sake of compatibility we should not replace pkg_resources with importlib just yet.
  • The reason why pkg_resources was used in the first place was to identify the pywbem module version. There were significant differences between the "original" pywbem 0.7 and newer releases. However pywbem 0.7 is nowhere shipped anymore, in current active Linux distributions. EL8 for example ships python3-pywbem 0.11.0, Debian based distributions have completely removed the python3-pywbem package (can only be installed using pip now). The last Ubuntu LTS was 18.04 (Bionic) which shipped pywbem 0.8.0.

Now looking at this and assuming pywbem 0.7.0 is now definitely gone in active setups, I guess it's safe to remove the "different pywbem version handling" in the plugin. If, in the future, we run into new compatibility issues between certain pywbem versions, then we can use pywbem.__version__ which was added after pywbem 0.7.0 (don't remember the exact release).

Besides this, all active Linux distributions, including LTS releases, come with python3. There might still be some older LTS releases out there which ship both python2 and python3, but this means that python3 is available on all active setups. This means we can also get rid of the "python2 to python3 translation" (for the print function).

@Napsty
Copy link
Owner

Napsty commented Oct 25, 2024

All, please have a look at #73 and let me know your thoughts.
In the meantime I deploy the python3 only plugin on my monitoring environments to verify everything works.

@Napsty
Copy link
Owner

Napsty commented Oct 30, 2024

FYI, I plan to release the new version (python3 only) on November 1st 2024, unless a blocker-comment comes up in between.

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

Successfully merging a pull request may close this issue.

3 participants