Skip to content

Commit e79a57a

Browse files
migrate to selectable entrypoints
1 parent 9fcaffa commit e79a57a

File tree

4 files changed

+14
-24
lines changed

4 files changed

+14
-24
lines changed

src/setuptools_scm/_entrypoints.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,10 @@
1919

2020
if sys.version_info[:2] < (3, 10):
2121
from importlib_metadata import EntryPoint as EntryPoint
22-
from importlib_metadata import EntryPoints
23-
from importlib_metadata import entry_points
22+
from importlib_metadata import entry_points as entry_points
2423
else:
2524
from importlib.metadata import EntryPoint as EntryPoint
26-
from importlib.metadata import EntryPoints
27-
from importlib.metadata import entry_points
25+
from importlib.metadata import entry_points as entry_points
2826

2927

3028
log = _log.log.getChild("entrypoints")
@@ -45,15 +43,8 @@ def version_from_entrypoint(
4543
return None
4644

4745

48-
def iter_entry_points(group: str, name: str | None = None) -> Iterator[EntryPoint]:
49-
eps: EntryPoints = entry_points(group=group)
50-
res = eps if name is None else eps.select(name=name)
51-
52-
return iter(res)
53-
54-
5546
def _get_ep(group: str, name: str) -> Any | None:
56-
for ep in iter_entry_points(group, name):
47+
for ep in entry_points(group=group, name=name):
5748
log.debug("ep found: %s", ep.name)
5849
return ep.load()
5950
return None

src/setuptools_scm/_file_finders/__init__.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
from __future__ import annotations
22

3-
import itertools
43
import os
54

65
from typing import TYPE_CHECKING
76
from typing import Callable
87

98
from .. import _log
109
from .. import _types as _t
11-
from .._entrypoints import iter_entry_points
10+
from .._entrypoints import EntryPoint
11+
from .._entrypoints import entry_points
1212
from .pathtools import norm_real
1313

1414
if TYPE_CHECKING:
@@ -102,10 +102,11 @@ def is_toplevel_acceptable(toplevel: str | None) -> TypeGuard[str]:
102102

103103

104104
def find_files(path: _t.PathT = "") -> list[str]:
105-
for ep in itertools.chain(
106-
iter_entry_points("setuptools_scm.files_command"),
107-
iter_entry_points("setuptools_scm.files_command_fallback"),
108-
):
105+
eps: list[EntryPoint] = [
106+
*entry_points(group="setuptools_scm.files_command"),
107+
*entry_points(group="setuptools_scm.files_command_fallback"),
108+
]
109+
for ep in eps:
109110
command: Callable[[_t.PathT], list[str]] = ep.load()
110111
res: list[str] = command(path)
111112
if res:

src/setuptools_scm/discover.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,9 @@ def iter_matching_entrypoints(
5858
"""
5959

6060
log.debug("looking for ep %s in %s", entrypoint, root)
61-
from ._entrypoints import iter_entry_points
6261

6362
for wd in walk_potential_roots(root, config.search_parent_directories):
64-
for ep in iter_entry_points(entrypoint):
63+
for ep in _entrypoints.entry_points(group=entrypoint):
6564
if ep.value in _BLOCKED_EP_TARGETS:
6665
continue
6766
if match_entrypoint(wd, ep.name):

src/setuptools_scm/version.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,10 @@ def callable_or_entrypoint(group: str, callable_or_name: str | Any) -> Any:
8282

8383
if callable(callable_or_name):
8484
return callable_or_name
85-
from ._entrypoints import iter_entry_points
8685

87-
for ep in iter_entry_points(group, callable_or_name):
88-
log.debug("ep found: %s", ep.name)
89-
return ep.load()
86+
from ._entrypoints import _get_ep
87+
88+
return _get_ep(group, callable_or_name)
9089

9190

9291
def tag_to_version(

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy