File tree Expand file tree Collapse file tree 3 files changed +15
-8
lines changed Expand file tree Collapse file tree 3 files changed +15
-8
lines changed Original file line number Diff line number Diff line change 1
1
"""The registry module provides some simple convenience functions to enable
2
2
applications to dynamically register and look-up codec classes."""
3
+ from importlib .metadata import entry_points
3
4
import logging
4
- from contextlib import suppress
5
5
6
6
logger = logging .getLogger ("numcodecs" )
7
7
codec_registry = {}
8
8
entries = {}
9
9
10
10
11
11
def run_entrypoints ():
12
- import entrypoints
13
12
entries .clear ()
14
- entries .update (entrypoints .get_group_named ("numcodecs.codecs" ))
13
+ eps = entry_points ()
14
+ if hasattr (eps , 'select' ):
15
+ # If entry_points() has a select method, use that. Python 3.10+
16
+ entries .update (eps .select (group = "numcodecs.codecs" ))
17
+ else :
18
+ # Otherwise, fallback to using get
19
+ entries .update (eps .get ("numcodecs.codecs" , []))
15
20
16
21
17
- with suppress (ImportError ):
18
- run_entrypoints ()
22
+ run_entrypoints ()
19
23
20
24
21
25
def get_codec (config ):
Original file line number Diff line number Diff line change 7
7
8
8
9
9
here = os .path .abspath (os .path .dirname (__file__ ))
10
- pytest .importorskip ("entrypoints" )
11
10
12
11
13
12
@pytest .fixture ()
@@ -20,7 +19,6 @@ def set_path():
20
19
numcodecs .registry .codec_registry .pop ("test" )
21
20
22
21
23
- @pytest .mark .xfail (reason = "FIXME: not working in wheels build" )
24
22
def test_entrypoint_codec (set_path ):
25
23
cls = numcodecs .registry .get_codec ({"id" : "test" })
26
24
assert cls .codec_id == "test"
Original file line number Diff line number Diff line change @@ -15,7 +15,6 @@ in data storage and communication applications.
15
15
"""
16
16
readme = " README.rst"
17
17
dependencies = [
18
- " entrypoints" ,
19
18
" numpy>=1.7" ,
20
19
]
21
20
requires-python = " >=3.8"
@@ -71,6 +70,12 @@ package-dir = {"" = "."}
71
70
packages = [" numcodecs" , " numcodecs.tests" ]
72
71
zip-safe = false
73
72
73
+ [tool .setuptools .package-data ]
74
+ numcodecs = [
75
+ " tests/package_with_entrypoint/__init__.py" ,
76
+ " tests/package_with_entrypoint-0.1.dist-info/entry_points.txt"
77
+ ]
78
+
74
79
[tool .setuptools_scm ]
75
80
version_scheme = " guess-next-dev"
76
81
local_scheme = " dirty-tag"
You can’t perform that action at this time.
0 commit comments