Repository: opendatacube/datacube-core

Issue:
DeprecationWarning on `pkg_resources` in Python 3.10
### Expected behaviour
ODC running in Python 3.10 shouldn't print `DeprecationWarning`s.

### Actual behaviour

When running some ODC code:
```
  .../testenv/lib/python3.10/site-packages/datacube/drivers/driver_cache.py:54: DeprecationWarning: pkg_resources is deprecated as an API
    from pkg_resources import iter_entry_points
```
Which is: https://github.com/opendatacube/datacube-core/blob/develop/datacube/drivers/driver_cache.py#L29

This code should be replaced with modules from the Python standard library, see: [Package Discovery and Resource Access using pkg_resources - setuptools 68.0.0.post20230621 documentation](https://setuptools.pypa.io/en/latest/pkg_resources.html) and [importlib.resources – Resources — Python 3.11.4 documentation](https://docs.python.org/3/library/importlib.resources.html#module-importlib.resources).

We've already set the minimum Python version as 3.8, and the stdlib modules exist since 3.7, so we don't need to add the external backports as dependencies.

### Environment information

* Which ``datacube --version`` are you using?
   `Open Data Cube core, version 1.8.13`
* What datacube deployment/enviornment are you running against?
   Local installation from conda-forge.




Discussion:

Resolving patch:
diff --git a/datacube/drivers/driver_cache.py b/datacube/drivers/driver_cache.py
--- a/datacube/drivers/driver_cache.py
+++ b/datacube/drivers/driver_cache.py
@@ -26,14 +26,9 @@ def load_drivers(group: str) -> Dict[str, Any]:
     """
 
     def safe_load(ep):
-        from pkg_resources import DistributionNotFound
         # pylint: disable=broad-except,bare-except
         try:
             driver_init = ep.load()
-        except DistributionNotFound:
-            # This happens when entry points were marked with extra features,
-            # but extra feature were not requested for installation
-            return None
         except Exception as e:
             _LOG.warning('Failed to resolve driver %s::%s', group, ep.name)
             _LOG.warning('Error was: %s', repr(e))
@@ -51,8 +46,8 @@ def safe_load(ep):
         return driver
 
     def resolve_all(group: str) -> Iterable[Tuple[str, Any]]:
-        from pkg_resources import iter_entry_points
-        for ep in iter_entry_points(group=group, name=None):
+        from importlib.metadata import entry_points
+        for ep in entry_points(group=group):
             driver = safe_load(ep)
             if driver is not None:
                 yield (ep.name, driver)
diff --git a/docs/click_utils.py b/docs/click_utils.py
--- a/docs/click_utils.py
+++ b/docs/click_utils.py
@@ -2,7 +2,7 @@
 #
 # Copyright (c) 2015-2023 ODC Contributors
 # SPDX-License-Identifier: Apache-2.0
-import pkg_resources
+from importlib.metadata import entry_points
 from docutils.nodes import literal_block, section, title, make_id
 from sphinx.domains import Domain
 from docutils.parsers.rst import Directive
@@ -34,8 +34,8 @@ def find_script_callable_from_env(name, env):
 
 
 def find_script_callable(name):
-    return list(pkg_resources.iter_entry_points(
-        'console_scripts', name))[0].load()
+    return list(entry_points(
+        group='console_scripts', name=name))[0].load()
 
 
 def generate_help_text(command, prefix):


Test patch: