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

respect metadata_directory at editable builds #537

Merged
merged 2 commits into from
Dec 20, 2022
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
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
45 changes: 41 additions & 4 deletions tests/masonry/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,19 +238,56 @@ def test_build_editable_wheel() -> None:


def test_build_wheel_with_metadata_directory() -> None:
with temporary_directory() as metadata_tmp_dir, cwd(
os.path.join(fixtures, "complete")
):
pkg_dir = Path(fixtures) / "complete"

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

with temporary_directory() as wheel_tmp_dir:
dist_info_path = Path(metadata_tmp_dir) / metadata_directory
open(dist_info_path / "CUSTOM", "w").close() # noqa: SIM115
filename = api.build_wheel(
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(os.path.join(wheel_tmp_dir, filename)),
path=str(wheel_pth),
files=["entry_points.txt"],
)

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

assert f"{metadata_directory}/CUSTOM" in namelist


def test_build_editable_wheel_with_metadata_directory() -> None:
radoering marked this conversation as resolved.
Show resolved Hide resolved
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
open(dist_info_path / "CUSTOM", "w").close() # noqa: SIM115
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()
assert f"{metadata_directory}/CUSTOM" in namelist