Update deprecated `distutils.version` to `packaging.version` by sadielbartholomew · Pull Request #324 · NCAS-CMS/cf-python
When running test modules e.g. test_Data under pytest (as can be done via $ pytest <test module> even though we don't strictly use pytest but unittest), I get multiple deprecation warnings on several uses of distutils.version.LooseVersion, all in cf/__init__.py:
DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead. g["version"][version] = LooseVersion(version)
I have updated these here to packaging.version.Version; it actually wasn't at all clear in any of the relevant documentation as to which class from that module would be the appropriate replacement, but from doing a full-GitHub search on relevant keywords I found the following comments (this and this) and corresponding PR to xarray, along with a few other similar PRs on major libraries, to confirm that Version is the best one to go with.
Unfortunately packaging isn't a built-in, so this change prompted by the deprecation warning does necessitate another dependency, which I have added to the requirements list and documentation of those.
@davidhassell can I check with you that it is OK to add this new dependency? (I am not too pleased that an entire new dependency is required to upgrade deprecated API usage, but this is what the warning prompts us to use. If you can think of an alternative approach, do let me know...)