From 819fbad836952d988fe3a8bc7f56474584a37715 Mon Sep 17 00:00:00 2001 From: David Ware Date: Wed, 24 May 2023 11:13:30 +1200 Subject: [PATCH 1/7] Make find_files behavior opt-in. Changes it so find_files is only enabled with config parameter `enable_find_files` is set to true, otherwise will always return empty list. --- README.rst | 6 ++-- src/setuptools_scm/_config.py | 1 + src/setuptools_scm/_file_finders/__init__.py | 38 +++++++++++++++----- testing/test_file_finder.py | 22 ++++++++++-- testing/test_git.py | 9 +++++ 5 files changed, 63 insertions(+), 13 deletions(-) diff --git a/README.rst b/README.rst index a48309c1..702343b4 100644 --- a/README.rst +++ b/README.rst @@ -7,8 +7,9 @@ or in a SCM managed file. Additionally ``setuptools_scm`` provides setuptools with a list of files that are managed by the SCM (i.e. it automatically adds all of -the SCM-managed files to the sdist). Unwanted files must be excluded -by discarding them via ``MANIFEST.in``. +the SCM-managed files to the sdist). This is opt-in, by supplying +config argument: ``enable_find_files``. Once opted in unwanted files +must be excluded by discarding them via ``MANIFEST.in``. ``setuptools_scm`` supports the following scm out of the box: @@ -77,6 +78,7 @@ to be supplied to ``get_version()``. For example: # pyproject.toml [tool.setuptools_scm] write_to = "pkg/_version.py" + enable_find_files = true Where ``pkg`` is the name of your package. diff --git a/src/setuptools_scm/_config.py b/src/setuptools_scm/_config.py index 108c86e7..d34e1e47 100644 --- a/src/setuptools_scm/_config.py +++ b/src/setuptools_scm/_config.py @@ -90,6 +90,7 @@ class Configuration: dist_name: str | None = None version_cls: type[_VersionT] = _Version search_parent_directories: bool = False + enable_find_files: bool = False parent: _t.PathT | None = None diff --git a/src/setuptools_scm/_file_finders/__init__.py b/src/setuptools_scm/_file_finders/__init__.py index 90726c45..e22529ce 100644 --- a/src/setuptools_scm/_file_finders/__init__.py +++ b/src/setuptools_scm/_file_finders/__init__.py @@ -2,12 +2,14 @@ import itertools import os -from typing import Callable +from typing import Callable, Optional from typing import TYPE_CHECKING +from .. import _config from .. import _log from .. import _types as _t from .._entrypoints import iter_entry_points +from .._integration.setuptools import read_dist_name_from_setup_cfg if TYPE_CHECKING: from typing_extensions import TypeGuard @@ -94,13 +96,31 @@ def is_toplevel_acceptable(toplevel: str | None) -> TypeGuard[str]: return toplevel not in ignored +def _get_config() -> Optional[_config.Configuration]: + dist_name: Optional[str] = None + config: Optional[_config.Configuration] = None + if dist_name is None: + dist_name = read_dist_name_from_setup_cfg() + if not os.path.isfile("pyproject.toml"): + return None + if dist_name == "setuptools_scm": + return None + try: + config = _config.Configuration.from_file(dist_name=dist_name) + except LookupError as e: + log.exception(e) + return config + + def find_files(path: _t.PathT = "") -> list[str]: - for ep in itertools.chain( - iter_entry_points("setuptools_scm.files_command"), - iter_entry_points("setuptools_scm.files_command_fallback"), - ): - command: Callable[[_t.PathT], list[str]] = ep.load() - res: list[str] = command(path) - if res: - return res + config = _get_config() + if config is not None and config.enable_find_files: + for ep in itertools.chain( + iter_entry_points("setuptools_scm.files_command"), + iter_entry_points("setuptools_scm.files_command_fallback"), + ): + command: Callable[[_t.PathT], list[str]] = ep.load() + res: list[str] = command(path) + if res: + return res return [] diff --git a/testing/test_file_finder.py b/testing/test_file_finder.py index 3825500d..3dae4167 100644 --- a/testing/test_file_finder.py +++ b/testing/test_file_finder.py @@ -2,6 +2,7 @@ import os import sys +from pathlib import Path from typing import Generator from typing import Iterable @@ -11,6 +12,11 @@ from setuptools_scm._file_finders import find_files +def _write_pyproject_config(directory: Path, enable_find_files: bool) -> None: + with open(directory / "pyproject.toml", "wt") as fh: + fh.write(f"[project]\nname = \"test\"\n[tool.setuptools_scm]\nenable_find_files = {str(enable_find_files).lower()}\n") + + @pytest.fixture(params=["git", "hg"]) def inwd( request: pytest.FixtureRequest, wd: WorkDir, monkeypatch: pytest.MonkeyPatch @@ -42,6 +48,7 @@ def inwd( if request.node.get_closest_marker("skip_commit") is None: wd.add_and_commit() monkeypatch.chdir(wd.cwd) + _write_pyproject_config(wd.cwd, True) yield wd @@ -55,6 +62,13 @@ def test_basic(inwd: WorkDir) -> None: assert set(find_files("adir")) == _sep({"adir/filea"}) +def test_basic_find_files_disabled(inwd: WorkDir) -> None: + _write_pyproject_config(inwd.cwd, False) + assert find_files() == [] + assert find_files(".") == [] + assert find_files("adir") == [] + + def test_whitespace(inwd: WorkDir) -> None: (inwd.cwd / "adir" / "space file").touch() inwd.add_and_commit() @@ -66,7 +80,7 @@ def test_case(inwd: WorkDir) -> None: (inwd.cwd / "file2").touch() inwd.add_and_commit() assert set(find_files()) == _sep( - {"CamelFile", "file2", "file1", "adir/filea", "bdir/fileb"} + {"CamelFile", "file2", "file1", "adir/filea", "bdir/fileb", "pyproject.toml"} ) @@ -174,6 +188,7 @@ def test_double_include_through_symlink(inwd: WorkDir) -> None: "adir/filea", "bdir/fileb", "data/datafile", + "pyproject.toml" } ) @@ -193,6 +208,7 @@ def test_symlink_not_in_scm_while_target_is(inwd: WorkDir) -> None: # because the symlink_to themselves are not in scm "bdir/fileb", "data/datafile", + "pyproject.toml" } ) @@ -207,6 +223,7 @@ def test_unexpanded_git_archival(wd: WorkDir, monkeypatch: pytest.MonkeyPatch) - # When substitutions in `.git_archival.txt` are not expanded, files should # not be automatically listed. monkeypatch.chdir(wd.cwd) + _write_pyproject_config(wd.cwd, True) (wd.cwd / ".git_archival.txt").write_text("node: $Format:%H$", encoding="utf-8") (wd.cwd / "file1.txt").touch() assert find_files() == [] @@ -219,6 +236,7 @@ def test_archive( # When substitutions in `.git_archival.txt` are not expanded, files should # not be automatically listed. monkeypatch.chdir(wd.cwd) + _write_pyproject_config(wd.cwd, True) sha = "a1bda3d984d1a40d7b00ae1d0869354d6d503001" (wd.cwd / archive_file).write_text(f"node: {sha}", encoding="utf-8") (wd.cwd / "data").mkdir() @@ -230,4 +248,4 @@ def test_archive( else: os.link("data/datafile", datalink) - assert set(find_files()) == _sep({archive_file, "data/datafile", "data/datalink"}) + assert set(find_files()) == _sep({archive_file, "data/datafile", "data/datalink", "pyproject.toml"}) diff --git a/testing/test_git.py b/testing/test_git.py index 9e2e9b5c..da1edac5 100644 --- a/testing/test_git.py +++ b/testing/test_git.py @@ -33,6 +33,11 @@ ) +def _write_pyproject_config(directory: Path, enable_find_files: bool) -> None: + with open(directory / "pyproject.toml", "wt") as fh: + fh.write(f"[project]\nname = \"test\"\n[tool.setuptools_scm]\nenable_find_files = {str(enable_find_files).lower()}\n") + + @pytest.fixture(name="wd") def wd(wd: WorkDir, monkeypatch: pytest.MonkeyPatch, debug_mode: DebugMode) -> WorkDir: debug_mode.disable() @@ -98,6 +103,7 @@ def test_git_gone(wd: WorkDir, monkeypatch: pytest.MonkeyPatch) -> None: @pytest.mark.issue("https://github.com/pypa/setuptools_scm/issues/298") @pytest.mark.issue(403) def test_file_finder_no_history(wd: WorkDir, caplog: pytest.LogCaptureFixture) -> None: + _write_pyproject_config(wd.cwd, True) file_list = git_find_files(str(wd.cwd)) assert file_list == [] @@ -359,6 +365,7 @@ def test_git_archive_export_ignore( wd("git add test1.txt test2.txt") wd.commit() monkeypatch.chdir(wd.cwd) + _write_pyproject_config(wd.cwd, True) assert setuptools_scm._file_finders.find_files(".") == [opj(".", "test1.txt")] @@ -369,6 +376,7 @@ def test_git_archive_subdirectory(wd: WorkDir, monkeypatch: pytest.MonkeyPatch) wd("git add foobar") wd.commit() monkeypatch.chdir(wd.cwd) + _write_pyproject_config(wd.cwd, True) assert setuptools_scm._file_finders.find_files(".") == [ opj(".", "foobar", "test1.txt") ] @@ -383,6 +391,7 @@ def test_git_archive_run_from_subdirectory( wd("git add foobar") wd.commit() monkeypatch.chdir(wd.cwd / "foobar") + _write_pyproject_config(wd.cwd / "foobar", True) assert setuptools_scm._file_finders.find_files(".") == [opj(".", "test1.txt")] From a4242f731f0f3de97bcd4acba73dc8d518162c02 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 23 May 2023 23:22:32 +0000 Subject: [PATCH 2/7] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/setuptools_scm/_file_finders/__init__.py | 9 +++++---- testing/test_file_finder.py | 14 +++++++++----- testing/test_git.py | 6 ++++-- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/setuptools_scm/_file_finders/__init__.py b/src/setuptools_scm/_file_finders/__init__.py index e22529ce..f8983efa 100644 --- a/src/setuptools_scm/_file_finders/__init__.py +++ b/src/setuptools_scm/_file_finders/__init__.py @@ -2,7 +2,8 @@ import itertools import os -from typing import Callable, Optional +from typing import Callable +from typing import Optional from typing import TYPE_CHECKING from .. import _config @@ -96,9 +97,9 @@ def is_toplevel_acceptable(toplevel: str | None) -> TypeGuard[str]: return toplevel not in ignored -def _get_config() -> Optional[_config.Configuration]: - dist_name: Optional[str] = None - config: Optional[_config.Configuration] = None +def _get_config() -> _config.Configuration | None: + dist_name: str | None = None + config: _config.Configuration | None = None if dist_name is None: dist_name = read_dist_name_from_setup_cfg() if not os.path.isfile("pyproject.toml"): diff --git a/testing/test_file_finder.py b/testing/test_file_finder.py index 3dae4167..18be0d36 100644 --- a/testing/test_file_finder.py +++ b/testing/test_file_finder.py @@ -13,8 +13,10 @@ def _write_pyproject_config(directory: Path, enable_find_files: bool) -> None: - with open(directory / "pyproject.toml", "wt") as fh: - fh.write(f"[project]\nname = \"test\"\n[tool.setuptools_scm]\nenable_find_files = {str(enable_find_files).lower()}\n") + with open(directory / "pyproject.toml", "w") as fh: + fh.write( + f'[project]\nname = "test"\n[tool.setuptools_scm]\nenable_find_files = {str(enable_find_files).lower()}\n' + ) @pytest.fixture(params=["git", "hg"]) @@ -188,7 +190,7 @@ def test_double_include_through_symlink(inwd: WorkDir) -> None: "adir/filea", "bdir/fileb", "data/datafile", - "pyproject.toml" + "pyproject.toml", } ) @@ -208,7 +210,7 @@ def test_symlink_not_in_scm_while_target_is(inwd: WorkDir) -> None: # because the symlink_to themselves are not in scm "bdir/fileb", "data/datafile", - "pyproject.toml" + "pyproject.toml", } ) @@ -248,4 +250,6 @@ def test_archive( else: os.link("data/datafile", datalink) - assert set(find_files()) == _sep({archive_file, "data/datafile", "data/datalink", "pyproject.toml"}) + assert set(find_files()) == _sep( + {archive_file, "data/datafile", "data/datalink", "pyproject.toml"} + ) diff --git a/testing/test_git.py b/testing/test_git.py index da1edac5..4eb26424 100644 --- a/testing/test_git.py +++ b/testing/test_git.py @@ -34,8 +34,10 @@ def _write_pyproject_config(directory: Path, enable_find_files: bool) -> None: - with open(directory / "pyproject.toml", "wt") as fh: - fh.write(f"[project]\nname = \"test\"\n[tool.setuptools_scm]\nenable_find_files = {str(enable_find_files).lower()}\n") + with open(directory / "pyproject.toml", "w") as fh: + fh.write( + f'[project]\nname = "test"\n[tool.setuptools_scm]\nenable_find_files = {str(enable_find_files).lower()}\n' + ) @pytest.fixture(name="wd") From 46e5ce5935bbda0484224f006851f37731d3af4b Mon Sep 17 00:00:00 2001 From: David Ware Date: Wed, 24 May 2023 14:55:41 +1200 Subject: [PATCH 3/7] Fix mercurial test --- testing/test_mercurial.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/testing/test_mercurial.py b/testing/test_mercurial.py index 1b35d11c..38f82211 100644 --- a/testing/test_mercurial.py +++ b/testing/test_mercurial.py @@ -19,6 +19,11 @@ ) +def _write_pyproject_config(directory: Path, enable_find_files: bool) -> None: + with open(directory / "pyproject.toml", "wt") as fh: + fh.write(f"[project]\nname = \"test\"\n[tool.setuptools_scm]\nenable_find_files = {str(enable_find_files).lower()}\n") + + @pytest.fixture def wd(wd: WorkDir) -> WorkDir: wd("hg init") @@ -71,6 +76,7 @@ def test_find_files_stop_at_root_hg( # issue 251 wd.add_and_commit() monkeypatch.chdir(project) + _write_pyproject_config(project, True) assert setuptools_scm._file_finders.find_files() == ["setup.cfg"] From 62b83ab0f232f6be03da3bff3cbca91ed689014c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 24 May 2023 02:58:38 +0000 Subject: [PATCH 4/7] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- testing/test_mercurial.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/testing/test_mercurial.py b/testing/test_mercurial.py index 38f82211..38d3267d 100644 --- a/testing/test_mercurial.py +++ b/testing/test_mercurial.py @@ -20,8 +20,10 @@ def _write_pyproject_config(directory: Path, enable_find_files: bool) -> None: - with open(directory / "pyproject.toml", "wt") as fh: - fh.write(f"[project]\nname = \"test\"\n[tool.setuptools_scm]\nenable_find_files = {str(enable_find_files).lower()}\n") + with open(directory / "pyproject.toml", "w") as fh: + fh.write( + f'[project]\nname = "test"\n[tool.setuptools_scm]\nenable_find_files = {str(enable_find_files).lower()}\n' + ) @pytest.fixture From 1fabd66670c28e1c5071c6a51eb89e64a2f5fc71 Mon Sep 17 00:00:00 2001 From: David Ware Date: Wed, 24 May 2023 15:00:04 +1200 Subject: [PATCH 5/7] fix style, move test helper method. --- src/setuptools_scm/_file_finders/__init__.py | 1 - testing/conftest.py | 10 ++++++++++ testing/test_file_finder.py | 17 +++++------------ testing/test_git.py | 17 +++++------------ testing/test_mercurial.py | 10 ++-------- 5 files changed, 22 insertions(+), 33 deletions(-) diff --git a/src/setuptools_scm/_file_finders/__init__.py b/src/setuptools_scm/_file_finders/__init__.py index f8983efa..f8725d89 100644 --- a/src/setuptools_scm/_file_finders/__init__.py +++ b/src/setuptools_scm/_file_finders/__init__.py @@ -3,7 +3,6 @@ import itertools import os from typing import Callable -from typing import Optional from typing import TYPE_CHECKING from .. import _config diff --git a/testing/conftest.py b/testing/conftest.py index ef5883c8..796db6c4 100644 --- a/testing/conftest.py +++ b/testing/conftest.py @@ -42,6 +42,16 @@ def pytest_addoption(parser: Any) -> None: ) +def write_pyproject_config(directory: Path, enable_find_files: bool) -> None: + with open(directory / "pyproject.toml", "w") as fh: + fh.write( + f'[project]\n' + f'name = "test"\n' + f'[tool.setuptools_scm]\n' + f'enable_find_files = {str(enable_find_files).lower()}\n' + ) + + class DebugMode(contextlib.AbstractContextManager): # type: ignore[type-arg] from setuptools_scm import _log as __module diff --git a/testing/test_file_finder.py b/testing/test_file_finder.py index 18be0d36..d067e65c 100644 --- a/testing/test_file_finder.py +++ b/testing/test_file_finder.py @@ -2,23 +2,16 @@ import os import sys -from pathlib import Path from typing import Generator from typing import Iterable import pytest +from .conftest import write_pyproject_config from .wd_wrapper import WorkDir from setuptools_scm._file_finders import find_files -def _write_pyproject_config(directory: Path, enable_find_files: bool) -> None: - with open(directory / "pyproject.toml", "w") as fh: - fh.write( - f'[project]\nname = "test"\n[tool.setuptools_scm]\nenable_find_files = {str(enable_find_files).lower()}\n' - ) - - @pytest.fixture(params=["git", "hg"]) def inwd( request: pytest.FixtureRequest, wd: WorkDir, monkeypatch: pytest.MonkeyPatch @@ -50,7 +43,7 @@ def inwd( if request.node.get_closest_marker("skip_commit") is None: wd.add_and_commit() monkeypatch.chdir(wd.cwd) - _write_pyproject_config(wd.cwd, True) + write_pyproject_config(wd.cwd, True) yield wd @@ -65,7 +58,7 @@ def test_basic(inwd: WorkDir) -> None: def test_basic_find_files_disabled(inwd: WorkDir) -> None: - _write_pyproject_config(inwd.cwd, False) + write_pyproject_config(inwd.cwd, False) assert find_files() == [] assert find_files(".") == [] assert find_files("adir") == [] @@ -225,7 +218,7 @@ def test_unexpanded_git_archival(wd: WorkDir, monkeypatch: pytest.MonkeyPatch) - # When substitutions in `.git_archival.txt` are not expanded, files should # not be automatically listed. monkeypatch.chdir(wd.cwd) - _write_pyproject_config(wd.cwd, True) + write_pyproject_config(wd.cwd, True) (wd.cwd / ".git_archival.txt").write_text("node: $Format:%H$", encoding="utf-8") (wd.cwd / "file1.txt").touch() assert find_files() == [] @@ -238,7 +231,7 @@ def test_archive( # When substitutions in `.git_archival.txt` are not expanded, files should # not be automatically listed. monkeypatch.chdir(wd.cwd) - _write_pyproject_config(wd.cwd, True) + write_pyproject_config(wd.cwd, True) sha = "a1bda3d984d1a40d7b00ae1d0869354d6d503001" (wd.cwd / archive_file).write_text(f"node: {sha}", encoding="utf-8") (wd.cwd / "data").mkdir() diff --git a/testing/test_git.py b/testing/test_git.py index 4eb26424..5e4a6437 100644 --- a/testing/test_git.py +++ b/testing/test_git.py @@ -16,7 +16,7 @@ import pytest import setuptools_scm._file_finders -from .conftest import DebugMode +from .conftest import DebugMode, write_pyproject_config from .wd_wrapper import WorkDir from setuptools_scm import Configuration from setuptools_scm import git @@ -33,13 +33,6 @@ ) -def _write_pyproject_config(directory: Path, enable_find_files: bool) -> None: - with open(directory / "pyproject.toml", "w") as fh: - fh.write( - f'[project]\nname = "test"\n[tool.setuptools_scm]\nenable_find_files = {str(enable_find_files).lower()}\n' - ) - - @pytest.fixture(name="wd") def wd(wd: WorkDir, monkeypatch: pytest.MonkeyPatch, debug_mode: DebugMode) -> WorkDir: debug_mode.disable() @@ -105,7 +98,7 @@ def test_git_gone(wd: WorkDir, monkeypatch: pytest.MonkeyPatch) -> None: @pytest.mark.issue("https://github.com/pypa/setuptools_scm/issues/298") @pytest.mark.issue(403) def test_file_finder_no_history(wd: WorkDir, caplog: pytest.LogCaptureFixture) -> None: - _write_pyproject_config(wd.cwd, True) + write_pyproject_config(wd.cwd, True) file_list = git_find_files(str(wd.cwd)) assert file_list == [] @@ -367,7 +360,7 @@ def test_git_archive_export_ignore( wd("git add test1.txt test2.txt") wd.commit() monkeypatch.chdir(wd.cwd) - _write_pyproject_config(wd.cwd, True) + write_pyproject_config(wd.cwd, True) assert setuptools_scm._file_finders.find_files(".") == [opj(".", "test1.txt")] @@ -378,7 +371,7 @@ def test_git_archive_subdirectory(wd: WorkDir, monkeypatch: pytest.MonkeyPatch) wd("git add foobar") wd.commit() monkeypatch.chdir(wd.cwd) - _write_pyproject_config(wd.cwd, True) + write_pyproject_config(wd.cwd, True) assert setuptools_scm._file_finders.find_files(".") == [ opj(".", "foobar", "test1.txt") ] @@ -393,7 +386,7 @@ def test_git_archive_run_from_subdirectory( wd("git add foobar") wd.commit() monkeypatch.chdir(wd.cwd / "foobar") - _write_pyproject_config(wd.cwd / "foobar", True) + write_pyproject_config(wd.cwd / "foobar", True) assert setuptools_scm._file_finders.find_files(".") == [opj(".", "test1.txt")] diff --git a/testing/test_mercurial.py b/testing/test_mercurial.py index 38d3267d..7c451b30 100644 --- a/testing/test_mercurial.py +++ b/testing/test_mercurial.py @@ -6,6 +6,7 @@ import pytest import setuptools_scm._file_finders +from .conftest import write_pyproject_config from setuptools_scm import Configuration from setuptools_scm._run_cmd import has_command from setuptools_scm.hg import archival_to_version @@ -19,13 +20,6 @@ ) -def _write_pyproject_config(directory: Path, enable_find_files: bool) -> None: - with open(directory / "pyproject.toml", "w") as fh: - fh.write( - f'[project]\nname = "test"\n[tool.setuptools_scm]\nenable_find_files = {str(enable_find_files).lower()}\n' - ) - - @pytest.fixture def wd(wd: WorkDir) -> WorkDir: wd("hg init") @@ -78,7 +72,7 @@ def test_find_files_stop_at_root_hg( # issue 251 wd.add_and_commit() monkeypatch.chdir(project) - _write_pyproject_config(project, True) + write_pyproject_config(project, True) assert setuptools_scm._file_finders.find_files() == ["setup.cfg"] From cf4b57a632c9986397c10d00594f0a96259a527b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 24 May 2023 03:11:50 +0000 Subject: [PATCH 6/7] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- testing/conftest.py | 6 +++--- testing/test_git.py | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/testing/conftest.py b/testing/conftest.py index 796db6c4..2629f377 100644 --- a/testing/conftest.py +++ b/testing/conftest.py @@ -45,10 +45,10 @@ def pytest_addoption(parser: Any) -> None: def write_pyproject_config(directory: Path, enable_find_files: bool) -> None: with open(directory / "pyproject.toml", "w") as fh: fh.write( - f'[project]\n' + f"[project]\n" f'name = "test"\n' - f'[tool.setuptools_scm]\n' - f'enable_find_files = {str(enable_find_files).lower()}\n' + f"[tool.setuptools_scm]\n" + f"enable_find_files = {str(enable_find_files).lower()}\n" ) diff --git a/testing/test_git.py b/testing/test_git.py index 5e4a6437..fad425ea 100644 --- a/testing/test_git.py +++ b/testing/test_git.py @@ -16,7 +16,8 @@ import pytest import setuptools_scm._file_finders -from .conftest import DebugMode, write_pyproject_config +from .conftest import DebugMode +from .conftest import write_pyproject_config from .wd_wrapper import WorkDir from setuptools_scm import Configuration from setuptools_scm import git From 7b1911e5db8ad9ad4dcee72784478c5673ea8dfc Mon Sep 17 00:00:00 2001 From: David Ware Date: Mon, 29 May 2023 16:27:56 +1200 Subject: [PATCH 7/7] Switch `enable_find_files` default to true (i.e. opt-out) --- README.rst | 7 ++++--- src/setuptools_scm/_config.py | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/README.rst b/README.rst index 702343b4..1384b2bd 100644 --- a/README.rst +++ b/README.rst @@ -7,9 +7,10 @@ or in a SCM managed file. Additionally ``setuptools_scm`` provides setuptools with a list of files that are managed by the SCM (i.e. it automatically adds all of -the SCM-managed files to the sdist). This is opt-in, by supplying -config argument: ``enable_find_files``. Once opted in unwanted files -must be excluded by discarding them via ``MANIFEST.in``. +the SCM-managed files to the sdist). Unwanted files must be excluded +by discarding them via ``MANIFEST.in``. It is also possible to +opt-out of this behavior by setting the ``enable_find_files`` config +argument to false. ``setuptools_scm`` supports the following scm out of the box: diff --git a/src/setuptools_scm/_config.py b/src/setuptools_scm/_config.py index d34e1e47..d7dbf916 100644 --- a/src/setuptools_scm/_config.py +++ b/src/setuptools_scm/_config.py @@ -90,7 +90,7 @@ class Configuration: dist_name: str | None = None version_cls: type[_VersionT] = _Version search_parent_directories: bool = False - enable_find_files: bool = False + enable_find_files: bool = True parent: _t.PathT | None = None