Skip to content

Commit

Permalink
Selectable entry points were introduced in Python 3.10. Use the impor…
Browse files Browse the repository at this point in the history
…tlib-metadata package for Python versions < 3.10
  • Loading branch information
heuer committed Oct 26, 2023
1 parent 406c718 commit 40de1b2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ classifiers = [
"Topic :: Utilities",
]
dependencies = [
"importlib-metadata>=3.6.0; python_version < '3.8'",
"importlib-metadata>=3.6.0; python_version < '3.10'",
]

[project.urls]
Expand Down
6 changes: 4 additions & 2 deletions segno/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -951,9 +951,11 @@ def __getattr__(self, name):
"""
if name.startswith('to_'):
try:
from importlib import metadata
except ImportError: # Python < 3.8
# Try to use the 3rd party lib first. This is required for
# Python versions < 3.10
import importlib_metadata as metadata
except ImportError:
from importlib import metadata
from functools import partial
for ep in metadata.entry_points(group='segno.plugin.converter',
name=name[3:]):
Expand Down

0 comments on commit 40de1b2

Please sign in to comment.