Skip to content

Commit

Permalink
masonry.api: fix builds of projects with includes
Browse files Browse the repository at this point in the history
  • Loading branch information
abn committed Jul 20, 2020
1 parent 1a84fb0 commit 0a2f2fa
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
6 changes: 3 additions & 3 deletions poetry/core/masonry/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def get_requires_for_build_wheel(config_settings=None):


def prepare_metadata_for_build_wheel(metadata_directory, config_settings=None):
poetry = Factory().create_poetry(Path("."))
poetry = Factory().create_poetry(Path(".").resolve())
builder = WheelBuilder(poetry)

dist_info = Path(metadata_directory, builder.dist_info)
Expand All @@ -52,14 +52,14 @@ def prepare_metadata_for_build_wheel(metadata_directory, config_settings=None):

def build_wheel(wheel_directory, config_settings=None, metadata_directory=None):
"""Builds a wheel, places it in wheel_directory"""
poetry = Factory().create_poetry(Path("."))
poetry = Factory().create_poetry(Path(".").resolve())

return unicode(WheelBuilder.make_in(poetry, Path(wheel_directory)))


def build_sdist(sdist_directory, config_settings=None):
"""Builds an sdist, places it in sdist_directory"""
poetry = Factory().create_poetry(Path("."))
poetry = Factory().create_poetry(Path(".").resolve())

path = SdistBuilder(poetry).build(Path(sdist_directory))

Expand Down
22 changes: 22 additions & 0 deletions tests/masonry/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,18 @@ def test_build_wheel():
assert "my_package-1.2.3.dist-info/METADATA" in namelist


def test_build_wheel_with_include():
with temporary_directory() as tmp_dir, cwd(os.path.join(fixtures, "with-include")):
filename = api.build_wheel(tmp_dir)

with zipfile.ZipFile(str(os.path.join(tmp_dir, filename))) as zip:
namelist = zip.namelist()

assert "with_include-1.2.3.dist-info/entry_points.txt" in namelist
assert "with_include-1.2.3.dist-info/WHEEL" in namelist
assert "with_include-1.2.3.dist-info/METADATA" in namelist


@pytest.mark.skipif(
sys.platform == "win32"
and sys.version_info <= (3, 6)
Expand Down Expand Up @@ -86,6 +98,16 @@ def test_build_sdist():
assert "my-package-1.2.3/LICENSE" in namelist


def test_build_sdist_with_include():
with temporary_directory() as tmp_dir, cwd(os.path.join(fixtures, "with-include")):
filename = api.build_sdist(tmp_dir)

with tarfile.open(str(os.path.join(tmp_dir, filename))) as tar:
namelist = tar.getnames()

assert "with-include-1.2.3/LICENSE" in namelist


def test_prepare_metadata_for_build_wheel():
entry_points = """\
[console_scripts]
Expand Down

0 comments on commit 0a2f2fa

Please sign in to comment.