Skip to content

Commit b39dc4c

Browse files
fix #914: ignore the deprecated git archival plugin
the functionality is now native
1 parent 9d83cb3 commit b39dc4c

File tree

4 files changed

+27
-1
lines changed

4 files changed

+27
-1
lines changed

CHANGELOG.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ v8.0.2
33

44
bugfix
55
------
6-
6+
* fix #914: ignore the deprecated git archival plugin as its integrated now
77
* fix #912: ensure mypy safety of the version template + regression test
88
* fix #913: use 240s timeout instead of 20 for git unshallow
99
to account for large repos or slow connections

src/setuptools_scm/_entrypoints.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
class EntrypointProtocol(Protocol):
2424
name: str
25+
value: str
2526

2627
def load(self) -> Any:
2728
pass
@@ -61,6 +62,7 @@ def iter_entry_points(
6162
name=name,
6263
)
6364
)
65+
6466
return cast(Iterator[EntrypointProtocol], iter(res))
6567

6668

src/setuptools_scm/discover.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ def match_entrypoint(root: _t.PathT, name: str) -> bool:
4141
return False
4242

4343

44+
# blocked entrypints from legacy plugins
45+
_BLOCKED_EP_TARGETS = {"setuptools_scm_git_archive:parse"}
46+
47+
4448
def iter_matching_entrypoints(
4549
root: _t.PathT, entrypoint: str, config: Configuration
4650
) -> Iterable[_entrypoints.EntrypointProtocol]:
@@ -57,6 +61,8 @@ def iter_matching_entrypoints(
5761

5862
for wd in walk_potential_roots(root, config.search_parent_directories):
5963
for ep in iter_entry_points(entrypoint):
64+
if ep.value in _BLOCKED_EP_TARGETS:
65+
continue
6066
if match_entrypoint(wd, ep.name):
6167
log.debug("found ep %s in %s", ep, wd)
6268
config.parent = wd

testing/test_integration.py

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

3+
import importlib.metadata
34
import sys
45
import textwrap
56
from pathlib import Path
@@ -8,11 +9,14 @@
89

910
import setuptools_scm._integration.setuptools
1011
from .wd_wrapper import WorkDir
12+
from setuptools_scm import Configuration
1113
from setuptools_scm._integration.setuptools import _warn_on_old_setuptools
1214
from setuptools_scm._overrides import PRETEND_KEY
1315
from setuptools_scm._overrides import PRETEND_KEY_NAMED
1416
from setuptools_scm._run_cmd import run
1517

18+
c = Configuration()
19+
1620

1721
@pytest.fixture
1822
def wd(wd: WorkDir) -> WorkDir:
@@ -183,3 +187,17 @@ def test_setuptools_version_keyword_ensures_regex(
183187

184188
dist = setuptools.Distribution({"name": "test"})
185189
version_keyword(dist, "use_scm_version", {"tag_regex": "(1.0)"})
190+
191+
192+
@pytest.mark.parametrize(
193+
"ep_name", ["setuptools_scm.parse_scm", "setuptools_scm.parse_scm_fallback"]
194+
)
195+
def test_git_archival_plugin_ignored(tmp_path: Path, ep_name: str) -> None:
196+
tmp_path.joinpath(".git_archival.txt").write_text("broken")
197+
dist = importlib.metadata.distribution("setuptools_scm_git_archive")
198+
print(dist.metadata["Name"], dist.version)
199+
from setuptools_scm.discover import iter_matching_entrypoints
200+
201+
found = list(iter_matching_entrypoints(tmp_path, config=c, entrypoint=ep_name))
202+
imports = [item.value for item in found]
203+
assert "setuptools_scm_git_archive:parse" not in imports

0 commit comments

Comments
 (0)