diff options
author | Anderson Bravalheri <andersonbravalheri@gmail.com> | 2022-02-19 20:30:10 +0000 |
---|---|---|
committer | Anderson Bravalheri <andersonbravalheri@gmail.com> | 2022-03-05 14:54:35 +0000 |
commit | 54f61809ed9da2a1ab3d14f7a8f06c3d74ad799c (patch) | |
tree | 5bf6f5454db4d87222c392f4b3602dc3f3da11b7 | |
parent | d3e62b109e0d6ec57dcf14207c7dd91610138666 (diff) | |
download | python-setuptools-git-54f61809ed9da2a1ab3d14f7a8f06c3d74ad799c.tar.gz |
Find namespaces by default when using config in 'pyproject.toml'
-rw-r--r-- | setuptools/config/expand.py | 2 | ||||
-rw-r--r-- | setuptools/config/setupcfg.py | 5 | ||||
-rw-r--r-- | setuptools/tests/config/test_expand.py | 5 | ||||
-rw-r--r-- | setuptools/tests/config/test_pyprojecttoml.py | 3 |
4 files changed, 6 insertions, 9 deletions
diff --git a/setuptools/config/expand.py b/setuptools/config/expand.py index cf034d69..9d51a0a8 100644 --- a/setuptools/config/expand.py +++ b/setuptools/config/expand.py @@ -249,7 +249,7 @@ def cmdclass( def find_packages( - *, namespaces=False, root_dir: Optional[_Path] = None, **kwargs + *, namespaces=True, root_dir: Optional[_Path] = None, **kwargs ) -> List[str]: """Works similarly to :func:`setuptools.find_packages`, but with all arguments given as keyword arguments. Moreover, ``where`` can be given diff --git a/setuptools/config/setupcfg.py b/setuptools/config/setupcfg.py index 76feb6cd..5a449655 100644 --- a/setuptools/config/setupcfg.py +++ b/setuptools/config/setupcfg.py @@ -580,15 +580,12 @@ class ConfigOptionsHandler(ConfigHandler["Distribution"]): if trimmed_value not in find_directives: return self._parse_list(value) - findns = trimmed_value == find_directives[1] - # Read function arguments from a dedicated section. find_kwargs = self.parse_section_packages__find( self.sections.get('packages.find', {}) ) - if findns: - find_kwargs["namespaces"] = True + find_kwargs["namespaces"] = (trimmed_value == find_directives[1]) return expand.find_packages(**find_kwargs) diff --git a/setuptools/tests/config/test_expand.py b/setuptools/tests/config/test_expand.py index 1898792b..2461347d 100644 --- a/setuptools/tests/config/test_expand.py +++ b/setuptools/tests/config/test_expand.py @@ -88,9 +88,10 @@ def test_resolve_class(): @pytest.mark.parametrize( 'args, pkgs', [ - ({"where": ["."]}, {"pkg", "other"}), - ({"where": [".", "dir1"]}, {"pkg", "other", "dir2"}), + ({"where": ["."], "namespaces": False}, {"pkg", "other"}), + ({"where": [".", "dir1"], "namespaces": False}, {"pkg", "other", "dir2"}), ({"namespaces": True}, {"pkg", "other", "dir1", "dir1.dir2"}), + ({}, {"pkg", "other", "dir1", "dir1.dir2"}), # default value for `namespaces` ] ) def test_find_packages(tmp_path, monkeypatch, args, pkgs): diff --git a/setuptools/tests/config/test_pyprojecttoml.py b/setuptools/tests/config/test_pyprojecttoml.py index 2132197d..395824bf 100644 --- a/setuptools/tests/config/test_pyprojecttoml.py +++ b/setuptools/tests/config/test_pyprojecttoml.py @@ -43,7 +43,6 @@ platforms = ["any"] [tool.setuptools.packages.find] where = ["src"] -namespaces = true [tool.setuptools.cmdclass] sdist = "pkg.mod.CustomSdist" @@ -74,7 +73,7 @@ def test_read_configuration(tmp_path): files = [ "src/pkg/__init__.py", - "src/other/nested/__init__.py", + "src/other/nested/__init__.py", # ensure namespaces are discovered by default "files/file.txt" ] for file in files: |