Skip to content

Commit 0e7b2d2

Browse files
fix sdist build for multiple readme files
1 parent cdf4ee5 commit 0e7b2d2

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,9 +328,9 @@ def find_files_to_add(self, exclude_build: bool = False) -> set[BuildIncludeFile
328328
# Include project files
329329
additional_files.add(Path("pyproject.toml"))
330330

331-
# add readme if it is specified
331+
# add readme files if it is specified
332332
if "readme" in self._poetry.local_config:
333-
additional_files.add(self._poetry.local_config["readme"])
333+
additional_files.update(self._poetry.local_config["readme"])
334334

335335
for additional_file in additional_files:
336336
file = BuildIncludeFile(

src/poetry/core/poetry.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ def __init__(
2525
self._package = package
2626
self._local_config = local_config
2727

28+
# readme entry must be a sequence: turns to 1-element tuple if not
29+
if isinstance(local_config.get("readme"), str):
30+
local_config["readme"] = (local_config.get("readme"),)
31+
2832
@property
2933
def pyproject(self) -> PyProjectTOML:
3034
return self._pyproject

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)