Skip to content

Commit

Permalink
Add reprod for pre-existing build dir failure
Browse files Browse the repository at this point in the history
  • Loading branch information
uranusjr committed May 21, 2020
1 parent 9999f0e commit a46de07
Showing 1 changed file with 50 additions and 6 deletions.
56 changes: 50 additions & 6 deletions tests/functional/test_new_resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

import pytest

from pip._vendor.packaging.utils import canonicalize_name

from tests.lib import (
create_basic_sdist_for_package,
create_basic_wheel_for_package,
Expand All @@ -14,20 +16,25 @@
def assert_installed(script, **kwargs):
ret = script.pip('list', '--format=json')
installed = set(
(val['name'], val['version'])
(canonicalize_name(val['name']), val['version'])
for val in json.loads(ret.stdout)
)
assert set(kwargs.items()) <= installed, \
"{!r} not all in {!r}".format(kwargs, installed)
expected = set((canonicalize_name(k), v) for k, v in kwargs.items())
assert expected <= installed, \
"{!r} not all in {!r}".format(expected, installed)


def assert_not_installed(script, *args):
ret = script.pip("list", "--format=json")
installed = set(val["name"] for val in json.loads(ret.stdout))
installed = set(
canonicalize_name(val["name"])
for val in json.loads(ret.stdout)
)
# None of the given names should be listed as installed, i.e. their
# intersection should be empty.
assert not (set(args) & installed), \
"{!r} contained in {!r}".format(args, installed)
expected = set(canonicalize_name(k) for k in args)
assert not (expected & installed), \
"{!r} contained in {!r}".format(expected, installed)


def assert_editable(script, *args):
Expand Down Expand Up @@ -801,3 +808,40 @@ def test_new_resolver_extra_merge_in_package(
requirement + "[dev]",
)
assert_installed(script, pkg="1.0.0", dep="1.0.0", depdev="1.0.0")


@pytest.mark.xfail(reason="pre-existing build directory")
def test_new_resolver_build_directory_error_zazo_19(script):
"""https://github.com/pradyunsg/zazo/issues/19#issuecomment-631615674
This will first resolve like this:
1. Pin pkg-b==2.0.0 (since pkg-b has fewer choices)
2. Pin pkg-a==3.0.0 -> Conflict due to dependency pkg-b<2
3. Pin pkg-b==1.0.0
Since pkg-b is only available as sdist, both the first and third steps
would trigger building from source. This causes the preparer to fail with
a message like this::
ERROR: pip can't proceed with requirements 'pkg-b ...' due to a
pre-existing build directory (...). This is likely due to a previous
installation that failed. pip is being responsible and not assuming it
can delete this. Please delete it and try again.
"""
create_basic_wheel_for_package(
script, "pkg_a", "3.0.0", depends=["pkg-b<2"],
)
create_basic_wheel_for_package(script, "pkg_a", "2.0.0")
create_basic_wheel_for_package(script, "pkg_a", "1.0.0")

create_basic_sdist_for_package(script, "pkg_b", "2.0.0")
create_basic_sdist_for_package(script, "pkg_b", "1.0.0")

script.pip(
"install", "--unstable-feature=resolver",
"--no-cache-dir", "--no-index",
"--find-links", script.scratch_path,
"pkg-a", "pkg-b",
)
assert_installed(script, pkg_a="2.0.0", pkg_b="1.0.0")

0 comments on commit a46de07

Please sign in to comment.