diff --git a/src/poetry/core/factory.py b/src/poetry/core/factory.py index 8c369f4a8..501e2641d 100644 --- a/src/poetry/core/factory.py +++ b/src/poetry/core/factory.py @@ -376,7 +376,15 @@ def _configure_package_poetry_specifics( package.exclude = exclude if packages := tool_poetry.get("packages"): - package.packages = packages + packages_ = [] + for p in packages: + formats = p.get("format", ["sdist", "wheel"]) + if not isinstance(formats, list): + formats = [formats] + + packages_.append({**p, "format": formats}) + + package.packages = packages_ @classmethod def create_dependency( diff --git a/tests/test_factory.py b/tests/test_factory.py index 5da4a1aaf..6ebc38694 100644 --- a/tests/test_factory.py +++ b/tests/test_factory.py @@ -354,15 +354,27 @@ def test_create_poetry_with_packages_and_includes() -> None: package = poetry.package assert package.packages == [ - {"include": "extra_dir/**/*.py"}, - {"include": "extra_dir/**/*.py"}, - {"include": "my_module.py"}, - {"include": "package_with_include"}, - {"include": "tests", "format": "sdist"}, + {"include": "extra_dir/**/*.py", "format": ["sdist", "wheel"]}, + {"include": "extra_dir/**/*.py", "format": ["sdist", "wheel"]}, + {"include": "my_module.py", "format": ["sdist", "wheel"]}, + {"include": "package_with_include", "format": ["sdist", "wheel"]}, + { + "include": "tests", + "format": ["sdist"], + }, {"include": "for_wheel_only", "format": ["wheel"]}, - {"include": "src_package", "from": "src"}, - {"include": "from_to", "from": "etc", "to": "target_from_to"}, - {"include": "my_module_to.py", "to": "target_module"}, + {"include": "src_package", "from": "src", "format": ["sdist", "wheel"]}, + { + "include": "from_to", + "from": "etc", + "to": "target_from_to", + "format": ["sdist", "wheel"], + }, + { + "include": "my_module_to.py", + "to": "target_module", + "format": ["sdist", "wheel"], + }, ] assert package.include == [