mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-08-20 20:24:45 +03:00
Use importlib.metadata.entry_points to load PIL.Image.decoder entries on init()
This commit is contained in:
parent
6b8edca6df
commit
dd030343b8
|
@ -44,6 +44,12 @@ try:
|
||||||
except ImportError:
|
except ImportError:
|
||||||
ElementTree = None
|
ElementTree = None
|
||||||
|
|
||||||
|
try:
|
||||||
|
from importlib.metadata import entry_points
|
||||||
|
except ImportError:
|
||||||
|
# NB: potentially try to load entry_points from backported importlib_metadata?
|
||||||
|
entry_points = None
|
||||||
|
|
||||||
# VERSION was removed in Pillow 6.0.0.
|
# VERSION was removed in Pillow 6.0.0.
|
||||||
# PILLOW_VERSION was removed in Pillow 9.0.0.
|
# PILLOW_VERSION was removed in Pillow 9.0.0.
|
||||||
# Use __version__ instead.
|
# Use __version__ instead.
|
||||||
|
@ -374,6 +380,12 @@ def init():
|
||||||
except ImportError as e:
|
except ImportError as e:
|
||||||
logger.debug("Image: failed to import %s: %s", plugin, e)
|
logger.debug("Image: failed to import %s: %s", plugin, e)
|
||||||
|
|
||||||
|
if entry_points:
|
||||||
|
for decoder in entry_points(group='PIL.Image.decoder'):
|
||||||
|
# or, alternatively, register a decoder directly from here:
|
||||||
|
# DECODERS[decoder.name] = decoder.load()
|
||||||
|
decoder.load()
|
||||||
|
|
||||||
if OPEN or SAVE:
|
if OPEN or SAVE:
|
||||||
_initialized = 2
|
_initialized = 2
|
||||||
return 1
|
return 1
|
||||||
|
|
Loading…
Reference in New Issue
Block a user