Skip to content

Commit

Permalink
respect metadata_directory at editable builds
Browse files Browse the repository at this point in the history
  • Loading branch information
dimbleby committed Dec 4, 2022
1 parent 51e625d commit eef1f43
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/poetry/core/masonry/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,11 @@ def build_editable(
metadata_directory: str | None = None,
) -> str:
poetry = Factory().create_poetry(Path(".").resolve(), with_groups=False)
metadata_path = None if metadata_directory is None else Path(metadata_directory)

return WheelBuilder.make_in(poetry, Path(wheel_directory), editable=True)
return WheelBuilder.make_in(
poetry, Path(wheel_directory), metadata_directory=metadata_path, editable=True
)


get_requires_for_build_editable = get_requires_for_build_wheel
Expand Down
27 changes: 27 additions & 0 deletions tests/masonry/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,3 +254,30 @@ def test_build_wheel_with_metadata_directory() -> None:
path=str(os.path.join(wheel_tmp_dir, filename)),
files=["entry_points.txt"],
)


def test_build_editable_wheel_with_metadata_directory() -> None:
pkg_dir = Path(fixtures) / "complete"

with temporary_directory() as metadata_tmp_dir, cwd(pkg_dir):
metadata_directory = api.prepare_metadata_for_build_editable(metadata_tmp_dir)

with temporary_directory() as wheel_tmp_dir:
dist_info_path = Path(metadata_tmp_dir) / metadata_directory
filename = api.build_editable(
wheel_tmp_dir, metadata_directory=str(dist_info_path)
)
wheel_pth = Path(wheel_tmp_dir) / filename

validate_wheel_contents(
name="my_package",
version="1.2.3",
path=str(wheel_pth),
files=["entry_points.txt"],
)

with zipfile.ZipFile(wheel_pth) as z:
namelist = z.namelist()

assert "my_package.pth" in namelist
assert pkg_dir.as_posix() == z.read("my_package.pth").decode().strip()

0 comments on commit eef1f43

Please sign in to comment.