diff --git a/src/poetry/core/masonry/builders/builder.py b/src/poetry/core/masonry/builders/builder.py index 8fcc9ad3a..129a4c422 100644 --- a/src/poetry/core/masonry/builders/builder.py +++ b/src/poetry/core/masonry/builders/builder.py @@ -55,14 +55,14 @@ def _module(self) -> Module: packages: list[dict[str, Any]] = [] includes: list[dict[str, Any]] = [] - for source_list, target_list in [ - (self._package.packages, packages), - (self._package.include, includes), + for source_list, target_list, default in [ + (self._package.packages, packages, ["sdist", "wheel"]), + (self._package.include, includes, ["sdist"]), ]: for item in source_list: # Default to including in both sdist & wheel # if the `format` key is not provided. - formats = item.get("format", ["sdist", "wheel"]) + formats = item.get("format", default) if not isinstance(formats, list): formats = [formats] diff --git a/tests/masonry/builders/fixtures/exclude_nested_data_toml/pyproject.toml b/tests/masonry/builders/fixtures/exclude_nested_data_toml/pyproject.toml index 0747ae636..f18231f2c 100644 --- a/tests/masonry/builders/fixtures/exclude_nested_data_toml/pyproject.toml +++ b/tests/masonry/builders/fixtures/exclude_nested_data_toml/pyproject.toml @@ -10,7 +10,7 @@ license = "MIT" readme = "README.rst" exclude = ["**/data/", "**/*/item*"] -include = ["my_package/data/data2.txt"] +include = [{path = "my_package/data/data2.txt", format = ["sdist", "wheel"]}] homepage = "https://python-poetry.org/" repository = "https://github.com/python-poetry/poetry" diff --git a/tests/masonry/builders/fixtures/include_excluded_code/pyproject.toml b/tests/masonry/builders/fixtures/include_excluded_code/pyproject.toml index a69ea1808..0b6bf8e8f 100644 --- a/tests/masonry/builders/fixtures/include_excluded_code/pyproject.toml +++ b/tests/masonry/builders/fixtures/include_excluded_code/pyproject.toml @@ -8,7 +8,7 @@ packages = [{include='my_package', from='lib'}] # Simulate excluding due to .gitignore exclude = ['lib/my_package/generated.py'] # Include again -include = ['lib/my_package/generated.py'] +include = [{ path = 'lib/my_package/generated.py', format = ["sdist", "wheel"] }] [tool.poetry.dependencies] python = "^3.8" diff --git a/tests/masonry/builders/fixtures/with-include/pyproject.toml b/tests/masonry/builders/fixtures/with-include/pyproject.toml index 8650f524d..ad94f6467 100644 --- a/tests/masonry/builders/fixtures/with-include/pyproject.toml +++ b/tests/masonry/builders/fixtures/with-include/pyproject.toml @@ -33,8 +33,8 @@ packages = [ ] include = [ - "extra_dir/vcs_excluded.py", - "notes.txt" + { path = "extra_dir/vcs_excluded.py", format = ["sdist", "wheel"] }, + "notes.txt", # default is sdist only ] diff --git a/tests/masonry/builders/test_complete.py b/tests/masonry/builders/test_complete.py index 26d167caf..86a604175 100644 --- a/tests/masonry/builders/test_complete.py +++ b/tests/masonry/builders/test_complete.py @@ -347,7 +347,7 @@ def test_package_with_include(mocker: MockerFixture) -> None: assert "extra_dir/sub_pkg/vcs_excluded.py" not in names assert "for_wheel_only/__init__.py" in names assert "my_module.py" in names - assert "notes.txt" in names + assert "notes.txt" not in names assert "package_with_include/__init__.py" in names assert "tests/__init__.py" not in names assert "src_package/__init__.py" in names diff --git a/tests/masonry/builders/test_wheel.py b/tests/masonry/builders/test_wheel.py index 9ec0978be..6351b2f14 100644 --- a/tests/masonry/builders/test_wheel.py +++ b/tests/masonry/builders/test_wheel.py @@ -279,12 +279,12 @@ def test_wheel_include_formats() -> None: assert "pkg_both/__init__.py" in z.namelist() assert "pkg_both/sub/__init__.py" in z.namelist() # other includes - assert "default.txt" in z.namelist() + assert "default.txt" not in z.namelist() assert "sdist_only.txt" not in z.namelist() assert "wheel_only.txt" in z.namelist() assert "both.txt" in z.namelist() - assert "default/file.txt" in z.namelist() - assert "default/sub/file.txt" in z.namelist() + assert "default/file.txt" not in z.namelist() + assert "default/sub/file.txt" not in z.namelist() assert "sdist_only/file.txt" not in z.namelist() assert "sdist_only/sub/file.txt" not in z.namelist() assert "wheel_only/file.txt" in z.namelist() diff --git a/tests/test_factory.py b/tests/test_factory.py index d4ca3d262..b6d9cc34c 100644 --- a/tests/test_factory.py +++ b/tests/test_factory.py @@ -366,7 +366,7 @@ def test_create_poetry_with_packages_and_includes() -> None: ] assert package.include == [ - {"path": "extra_dir/vcs_excluded.py"}, + {"path": "extra_dir/vcs_excluded.py", "format": ["sdist", "wheel"]}, {"path": "notes.txt"}, ]