mirror of
https://github.com/explosion/spaCy.git
synced 2025-02-04 13:40:34 +03:00
Use importlib_metadata for entry points
This commit is contained in:
parent
5ed8c03afa
commit
9f071f5c40
|
@ -11,6 +11,7 @@ numpy>=1.15.0
|
||||||
requests>=2.13.0,<3.0.0
|
requests>=2.13.0,<3.0.0
|
||||||
plac<1.0.0,>=0.9.6
|
plac<1.0.0,>=0.9.6
|
||||||
pathlib==1.0.1; python_version < "3.4"
|
pathlib==1.0.1; python_version < "3.4"
|
||||||
|
importlib_metadata>=0.23; python_version < "3.8"
|
||||||
# Optional dependencies
|
# Optional dependencies
|
||||||
jsonschema>=2.6.0,<3.1.0
|
jsonschema>=2.6.0,<3.1.0
|
||||||
# Development dependencies
|
# Development dependencies
|
||||||
|
|
|
@ -50,6 +50,7 @@ install_requires =
|
||||||
wasabi>=0.2.0,<1.1.0
|
wasabi>=0.2.0,<1.1.0
|
||||||
srsly>=0.1.0,<1.1.0
|
srsly>=0.1.0,<1.1.0
|
||||||
pathlib==1.0.1; python_version < "3.4"
|
pathlib==1.0.1; python_version < "3.4"
|
||||||
|
importlib_metadata>=0.23; python_version < "3.8"
|
||||||
|
|
||||||
[options.extras_require]
|
[options.extras_require]
|
||||||
lookups =
|
lookups =
|
||||||
|
|
|
@ -35,6 +35,11 @@ try:
|
||||||
except ImportError:
|
except ImportError:
|
||||||
cupy = None
|
cupy = None
|
||||||
|
|
||||||
|
try: # Python 3.8
|
||||||
|
import importlib.metadata as importlib_metadata
|
||||||
|
except ImportError:
|
||||||
|
import importlib_metadata # noqa: F401
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from thinc.neural.optimizers import Optimizer # noqa: F401
|
from thinc.neural.optimizers import Optimizer # noqa: F401
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
|
|
@ -27,7 +27,7 @@ except ImportError:
|
||||||
|
|
||||||
from .symbols import ORTH
|
from .symbols import ORTH
|
||||||
from .compat import cupy, CudaStream, path2str, basestring_, unicode_
|
from .compat import cupy, CudaStream, path2str, basestring_, unicode_
|
||||||
from .compat import import_file
|
from .compat import import_file, importlib_metadata
|
||||||
from .errors import Errors, Warnings, deprecation_warning
|
from .errors import Errors, Warnings, deprecation_warning
|
||||||
|
|
||||||
|
|
||||||
|
@ -283,7 +283,8 @@ def get_entry_points(key):
|
||||||
RETURNS (dict): Entry points, keyed by name.
|
RETURNS (dict): Entry points, keyed by name.
|
||||||
"""
|
"""
|
||||||
result = {}
|
result = {}
|
||||||
for entry_point in pkg_resources.iter_entry_points(key):
|
eps = importlib_metadata.entry_points()
|
||||||
|
for entry_point in eps.get(key, []):
|
||||||
result[entry_point.name] = entry_point.load()
|
result[entry_point.name] = entry_point.load()
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@ -297,7 +298,8 @@ def get_entry_point(key, value, default=None):
|
||||||
default: Optional default value to return.
|
default: Optional default value to return.
|
||||||
RETURNS: The loaded entry point or None.
|
RETURNS: The loaded entry point or None.
|
||||||
"""
|
"""
|
||||||
for entry_point in pkg_resources.iter_entry_points(key):
|
eps = importlib_metadata.entry_points()
|
||||||
|
for entry_point in eps.get(key, []):
|
||||||
if entry_point.name == value:
|
if entry_point.name == value:
|
||||||
return entry_point.load()
|
return entry_point.load()
|
||||||
return default
|
return default
|
||||||
|
|
Loading…
Reference in New Issue
Block a user