charm-helpers icon indicating copy to clipboard operation
charm-helpers copied to clipboard

distutils package is deprecated and slated for removal in Python 3.12

Open hloeung opened this issue 3 years ago • 2 comments

Hi,

Seeing these warnings now:

.tox/unit/lib/python3.10/site-packages/charmhelpers/core/hookenv.py:21 /tmp/tmpfiles-hloeung/tmp/smtp-relay/.tox/unit/lib/python3.10/site-packages/charmhelpers/core/hookenv.py:21: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives from distutils.version import LooseVersion

Can we fix this before Python 3.12?

hloeung avatar Apr 28 '22 12:04 hloeung

PEP 632 mentions using the packaging package for distutils.version. Looks like this https://packaging.pypa.io/en/latest/version.html#packaging.version.Version

hloeung avatar Nov 03 '22 01:11 hloeung

I'm currently using this in the content-cache charm. In wheelhouse.txt:

 looseversion;python_version >= '3.12'

Then in the charm code:

try:
    from distutils.version import LooseVersion
except ImportError:
    from looseversion import LooseVersion

hloeung avatar Mar 13 '24 08:03 hloeung