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 broken sdist support due to missing egg fragment #178

Merged
merged 5 commits into from
Dec 2, 2020
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
1 change: 1 addition & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ def tests(session: Session) -> None:
session.install("dataclasses")

try:
session.env.pop("TMPDIR", None)
session.run("coverage", "run", "--parallel", "-m", "pytest", *session.posargs)
finally:
if session.interactive:
Expand Down
7 changes: 6 additions & 1 deletion src/nox_poetry/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,13 @@ def build_package(session: Session, *, distribution_format: DistributionFormat)
poetry = Poetry(session)
wheel = Path("dist") / poetry.build(format=distribution_format)
digest = hashlib.sha256(wheel.read_bytes()).hexdigest()
url = f"file://{wheel.resolve().as_posix()}#sha256={digest}"

return f"file://{wheel.resolve().as_posix()}#sha256={digest}"
if distribution_format is DistributionFormat.SDIST:
name = poetry.version().split()[0]
url += f"&egg={name}"

return url


def install(
Expand Down
16 changes: 16 additions & 0 deletions src/nox_poetry/poetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,19 @@ def build(self, *, format: DistributionFormat) -> str:
)
assert isinstance(output, str) # noqa: S101
return output.split()[-1]

def version(self) -> str:
"""Return the package name and version.

Returns:
The package name and version.
"""
output = self.session.run(
"poetry",
"version",
external=True,
silent=True,
stderr=None,
)
assert isinstance(output, str) # noqa: S101
return output.strip()
2 changes: 0 additions & 2 deletions tests/functional/test_functional.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Functional tests."""
import nox.sessions
import pytest
from tests.functional.conftest import ListPackages
from tests.functional.conftest import Project
from tests.functional.conftest import RunNoxWithNoxfile
Expand Down Expand Up @@ -48,7 +47,6 @@ def test(session: nox.sessions.Session) -> None:
assert set(expected) == set(packages)


@pytest.mark.xfail(reason="https://github.com/cjolowicz/nox-poetry/issues/127")
def test_install_local_sdist(
project: Project,
run_nox_with_noxfile: RunNoxWithNoxfile,
Expand Down
7 changes: 5 additions & 2 deletions tests/unit/test_nox_poetry.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
"""Unit tests."""
import pytest
from nox.sessions import Session

import nox_poetry
from nox_poetry.poetry import DistributionFormat


def test_install(session: Session) -> None:
@pytest.mark.parametrize("distribution_format", [nox_poetry.WHEEL, nox_poetry.SDIST])
def test_install(session: Session, distribution_format: DistributionFormat) -> None:
"""It installs the dependencies."""
nox_poetry.install(session, nox_poetry.WHEEL, "pip")
nox_poetry.install(session, distribution_format, "pip")


def test_export_requirements(session: Session) -> None:
Expand Down