Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix multiple packages build #292

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/poetry/core/masonry/builders/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,22 @@ def find_files_to_add(self, exclude_build: bool = True) -> Set["BuildIncludeFile
if "__pycache__" in str(file):
continue

if (
isinstance(include, PackageInclude)
and include.source
and self.format == "wheel"
):
source_root = include.base
else:
source_root = self._path

if file.is_dir():
if self.format in formats:
for current_file in file.glob("**/*"):
include_file = BuildIncludeFile(
path=current_file,
project_root=self._path,
source_root=self._path,
source_root=source_root,
)

if not current_file.is_dir() and not self.is_excluded(
Expand All @@ -185,15 +194,6 @@ def find_files_to_add(self, exclude_build: bool = True) -> Set["BuildIncludeFile
to_add.add(include_file)
continue

if (
isinstance(include, PackageInclude)
and include.source
and self.format == "wheel"
):
source_root = include.base
else:
source_root = self._path

include_file = BuildIncludeFile(
path=file, project_root=self._path, source_root=source_root
)
Expand Down
26 changes: 26 additions & 0 deletions tests/masonry/builders/test_complete.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,32 @@ def test_package_src():
zip.close()


def test_split_source():
module_path = fixtures_dir / "split_source"
abn marked this conversation as resolved.
Show resolved Hide resolved
builder = Builder(Factory().create_poetry(module_path))
builder.build(fmt="all")

sdist = module_path / "dist" / "split-source-0.1.tar.gz"

assert sdist.exists()

with tarfile.open(str(sdist), "r") as tar:
assert "split-source-0.1/lib_a/module_a/__init__.py" in tar.getnames()
assert "split-source-0.1/lib_b/module_b/__init__.py" in tar.getnames()

whl = module_path / "dist" / "split_source-0.1-py3-none-any.whl"

assert whl.exists()

zip = zipfile.ZipFile(str(whl))

try:
assert "module_a/__init__.py" in zip.namelist()
assert "module_b/__init__.py" in zip.namelist()
finally:
zip.close()


def test_package_with_include(mocker: "MockerFixture"):
module_path = fixtures_dir / "with-include"

Expand Down