Skip to content

Commit

Permalink
fix sdist build for multiple readme files
Browse files Browse the repository at this point in the history
  • Loading branch information
wagnerluis1982 committed Oct 1, 2022
1 parent 16c6e6c commit 9210d73
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/poetry/core/masonry/builders/sdist.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from pprint import pformat
from typing import TYPE_CHECKING
from typing import Iterator
from typing import Sequence

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

# add readme if it is specified
# add readme files if it is specified
if "readme" in self._poetry.local_config:
additional_files.add(self._poetry.local_config["readme"])
r: str | Sequence = self._poetry.local_config["readme"]
if isinstance(r, str):
additional_files.add(r)
else:
additional_files.update(r)

for additional_file in additional_files:
file = BuildIncludeFile(
Expand Down
18 changes: 18 additions & 0 deletions tests/masonry/builders/test_sdist.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,24 @@ def test_find_files_to_add() -> None:
)


def test_find_files_to_add_with_multiple_readme_files() -> None:
poetry = Factory().create_poetry(
Path(__file__).parent.parent.parent / "fixtures" / "with_readme_files"
)

builder = SdistBuilder(poetry)
result = [f.relative_to_source_root() for f in builder.find_files_to_add()]

assert sorted(result) == sorted(
[
Path("README-1.rst"),
Path("README-2.rst"),
Path("my_package/__init__.py"),
Path("pyproject.toml"),
]
)


def test_make_pkg_info_multi_constraints_dependency() -> None:
poetry = Factory().create_poetry(
Path(__file__).parent.parent.parent
Expand Down

0 comments on commit 9210d73

Please sign in to comment.