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 11"""The registry module provides some simple convenience functions to enable
22applications to dynamically register and look-up codec classes."""
3+ from importlib .metadata import entry_points
34import logging
4- from contextlib import suppress
55
66logger = logging .getLogger ("numcodecs" )
77codec_registry = {}
88entries = {}
99
1010
1111def run_entrypoints ():
12- import entrypoints
1312 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" , []))
1520
1621
17- with suppress (ImportError ):
18- run_entrypoints ()
22+ run_entrypoints ()
1923
2024
2125def get_codec (config ):
Original file line number Diff line number Diff line change 77
88
99here = os .path .abspath (os .path .dirname (__file__ ))
10- pytest .importorskip ("entrypoints" )
1110
1211
1312@pytest .fixture ()
@@ -20,7 +19,6 @@ def set_path():
2019 numcodecs .registry .codec_registry .pop ("test" )
2120
2221
23- @pytest .mark .xfail (reason = "FIXME: not working in wheels build" )
2422def test_entrypoint_codec (set_path ):
2523 cls = numcodecs .registry .get_codec ({"id" : "test" })
2624 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.
1515"""
1616readme = " README.rst"
1717dependencies = [
18- " entrypoints" ,
1918 " numpy>=1.7" ,
2019]
2120requires-python = " >=3.8"
@@ -71,6 +70,12 @@ package-dir = {"" = "."}
7170packages = [" numcodecs" , " numcodecs.tests" ]
7271zip-safe = false
7372
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+
7479[tool .setuptools_scm ]
7580version_scheme = " guess-next-dev"
7681local_scheme = " dirty-tag"
You can’t perform that action at this time.
0 commit comments