Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #914: ignore the deprecated git archival plugin #922

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ v8.0.2

bugfix
------

* fix #914: ignore the deprecated git archival plugin as its integrated now
* fix #912: ensure mypy safety of the version template + regression test
* fix #913: use 240s timeout instead of 20 for git unshallow
to account for large repos or slow connections
Expand Down
2 changes: 2 additions & 0 deletions src/setuptools_scm/_entrypoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

class EntrypointProtocol(Protocol):
name: str
value: str

def load(self) -> Any:
pass
Expand Down Expand Up @@ -61,6 +62,7 @@ def iter_entry_points(
name=name,
)
)

return cast(Iterator[EntrypointProtocol], iter(res))


Expand Down
6 changes: 6 additions & 0 deletions src/setuptools_scm/discover.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ def match_entrypoint(root: _t.PathT, name: str) -> bool:
return False


# blocked entrypints from legacy plugins
_BLOCKED_EP_TARGETS = {"setuptools_scm_git_archive:parse"}


def iter_matching_entrypoints(
root: _t.PathT, entrypoint: str, config: Configuration
) -> Iterable[_entrypoints.EntrypointProtocol]:
Expand All @@ -57,6 +61,8 @@ def iter_matching_entrypoints(

for wd in walk_potential_roots(root, config.search_parent_directories):
for ep in iter_entry_points(entrypoint):
if ep.value in _BLOCKED_EP_TARGETS:
continue
if match_entrypoint(wd, ep.name):
log.debug("found ep %s in %s", ep, wd)
config.parent = wd
Expand Down
22 changes: 22 additions & 0 deletions testing/test_integration.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import importlib.metadata
import sys
import textwrap
from pathlib import Path
Expand All @@ -8,11 +9,14 @@

import setuptools_scm._integration.setuptools
from .wd_wrapper import WorkDir
from setuptools_scm import Configuration
from setuptools_scm._integration.setuptools import _warn_on_old_setuptools
from setuptools_scm._overrides import PRETEND_KEY
from setuptools_scm._overrides import PRETEND_KEY_NAMED
from setuptools_scm._run_cmd import run

c = Configuration()


@pytest.fixture
def wd(wd: WorkDir) -> WorkDir:
Expand Down Expand Up @@ -183,3 +187,21 @@ def test_setuptools_version_keyword_ensures_regex(

dist = setuptools.Distribution({"name": "test"})
version_keyword(dist, "use_scm_version", {"tag_regex": "(1.0)"})


@pytest.mark.parametrize(
"ep_name", ["setuptools_scm.parse_scm", "setuptools_scm.parse_scm_fallback"]
)
def test_git_archival_plugin_ignored(tmp_path: Path, ep_name: str) -> None:
tmp_path.joinpath(".git_archival.txt").write_text("broken")
try:
dist = importlib.metadata.distribution("setuptools_scm_git_archive")
except importlib.metadata.PackageNotFoundError:
pytest.skip("setuptools_scm_git_archive not installed")
else:
print(dist.metadata["Name"], dist.version)
from setuptools_scm.discover import iter_matching_entrypoints

found = list(iter_matching_entrypoints(tmp_path, config=c, entrypoint=ep_name))
imports = [item.value for item in found]
assert "setuptools_scm_git_archive:parse" not in imports
Loading