diff --git a/noxfile.py b/noxfile.py index 628f1ed5..6c9dcabe 100644 --- a/noxfile.py +++ b/noxfile.py @@ -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: diff --git a/src/nox_poetry/core.py b/src/nox_poetry/core.py index 9bd65dc5..a9eea35d 100644 --- a/src/nox_poetry/core.py +++ b/src/nox_poetry/core.py @@ -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( diff --git a/src/nox_poetry/poetry.py b/src/nox_poetry/poetry.py index abb9f50e..73eb1c5a 100644 --- a/src/nox_poetry/poetry.py +++ b/src/nox_poetry/poetry.py @@ -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() diff --git a/tests/functional/test_functional.py b/tests/functional/test_functional.py index b4078481..58d120e9 100644 --- a/tests/functional/test_functional.py +++ b/tests/functional/test_functional.py @@ -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 @@ -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, diff --git a/tests/unit/test_nox_poetry.py b/tests/unit/test_nox_poetry.py index 701ad528..993281b6 100644 --- a/tests/unit/test_nox_poetry.py +++ b/tests/unit/test_nox_poetry.py @@ -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: