Skip to content

Commit 0d57c91

Browse files
fix sdist build for multiple readme files
1 parent 16c6e6c commit 0d57c91

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

src/poetry/core/masonry/builders/sdist.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from posixpath import join as pjoin
1515
from pprint import pformat
1616
from typing import TYPE_CHECKING
17+
from typing import Iterable
1718
from typing import Iterator
1819

1920
from poetry.core.masonry.builders.builder import Builder
@@ -328,9 +329,13 @@ def find_files_to_add(self, exclude_build: bool = False) -> set[BuildIncludeFile
328329
# Include project files
329330
additional_files.add(Path("pyproject.toml"))
330331

331-
# add readme if it is specified
332+
# add readme files if it is specified
332333
if "readme" in self._poetry.local_config:
333-
additional_files.add(self._poetry.local_config["readme"])
334+
r: str | Iterable = self._poetry.local_config["readme"]
335+
if isinstance(r, str):
336+
additional_files.add(r)
337+
else:
338+
additional_files.update(r)
334339

335340
for additional_file in additional_files:
336341
file = BuildIncludeFile(

tests/masonry/builders/test_sdist.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,24 @@ def test_find_files_to_add() -> None:
191191
)
192192

193193

194+
def test_find_files_to_add_with_multiple_readme_files() -> None:
195+
poetry = Factory().create_poetry(
196+
Path(__file__).parent.parent.parent / "fixtures" / "with_readme_files"
197+
)
198+
199+
builder = SdistBuilder(poetry)
200+
result = [f.relative_to_source_root() for f in builder.find_files_to_add()]
201+
202+
assert sorted(result) == sorted(
203+
[
204+
Path("README-1.rst"),
205+
Path("README-2.rst"),
206+
Path("my_package/__init__.py"),
207+
Path("pyproject.toml"),
208+
]
209+
)
210+
211+
194212
def test_make_pkg_info_multi_constraints_dependency() -> None:
195213
poetry = Factory().create_poetry(
196214
Path(__file__).parent.parent.parent

0 commit comments

Comments
 (0)