Skip to content

Commit

Permalink
Use entry_points selection interface for <3.10 compatibility (#1469)
Browse files Browse the repository at this point in the history
* use entry_points selection interface for <3.10 compatibility

* use importlib_metadata if python<3.10

---------

Co-authored-by: Ariana Barzinpour <ariana.barzinpour@ga.gov.au>
  • Loading branch information
Ariana-B and Ariana Barzinpour committed Jul 3, 2023
1 parent 5fed4a6 commit 353bb99
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
5 changes: 4 additions & 1 deletion datacube/drivers/driver_cache.py
Expand Up @@ -46,7 +46,10 @@ def safe_load(ep):
return driver

def resolve_all(group: str) -> Iterable[Tuple[str, Any]]:
from importlib.metadata import entry_points
try:
from importlib_metadata import entry_points
except ModuleNotFoundError:
from importlib.metadata import entry_points
for ep in entry_points(group=group):
driver = safe_load(ep)
if driver is not None:
Expand Down
5 changes: 4 additions & 1 deletion docs/click_utils.py
Expand Up @@ -2,7 +2,6 @@
#
# Copyright (c) 2015-2023 ODC Contributors
# SPDX-License-Identifier: Apache-2.0
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
Expand Down Expand Up @@ -34,6 +33,10 @@ def find_script_callable_from_env(name, env):


def find_script_callable(name):
try:
from importlib_metadata import entry_points
except ModuleNotFoundError:
from importlib.metadata import entry_points
return list(entry_points(
group='console_scripts', name=name))[0].load()

Expand Down
8 changes: 5 additions & 3 deletions docs/requirements.txt
@@ -1,5 +1,5 @@
#
# This file is autogenerated by pip-compile with Python 3.10
# This file is autogenerated by pip-compile with Python 3.11
# by the following command:
#
# pip-compile --extra=doc,s3 --output-file=docs/requirements.txt
Expand Down Expand Up @@ -70,6 +70,8 @@ dask[array]==2023.1.1
# distributed
defusedxml==0.7.1
# via nbconvert
deprecat==2.1.1
# via datacube (setup.py)
distributed==2023.1.1
# via datacube (setup.py)
docutils==0.17.1
Expand Down Expand Up @@ -216,8 +218,6 @@ requests==2.28.2
# via sphinx
ruamel-yaml==0.17.21
# via datacube (setup.py)
ruamel-yaml-clib==0.2.7
# via ruamel-yaml
s3transfer==0.6.0
# via boto3
shapely==2.0.1
Expand Down Expand Up @@ -294,6 +294,8 @@ webencodings==0.5.1
# via
# bleach
# tinycss2
wrapt==1.15.0
# via deprecat
xarray==2023.1.0
# via datacube (setup.py)
zict==2.2.0
Expand Down
1 change: 1 addition & 0 deletions setup.py
Expand Up @@ -112,6 +112,7 @@
'xarray>=0.9', # >0.9 fixes most problems with `crs` attributes being lost
'packaging',
'deprecat',
'importlib_metadata>3.5;python_version<"3.10"',
],
extras_require=extras_require,
tests_require=tests_require,
Expand Down

0 comments on commit 353bb99

Please sign in to comment.