Skip to content

Commit

Permalink
Discard un-find-able existing pins in favor of a find-able match. Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
AndydeCleyre committed Feb 8, 2022
1 parent 5f60ac7 commit d1a0651
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
10 changes: 8 additions & 2 deletions piptools/repositories/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

from piptools.utils import as_tuple, key_from_ireq, make_install_requirement

from ..exceptions import NoCandidateFound
from .base import BaseRepository
from .pypi import PyPIRepository

Expand Down Expand Up @@ -70,8 +71,13 @@ def find_best_match(
key = key_from_ireq(ireq)
existing_pin = self.existing_pins.get(key)
if existing_pin and ireq_satisfied_by_existing_pin(ireq, existing_pin):
project, version, _ = as_tuple(existing_pin)
return make_install_requirement(project, version, ireq)
try:
self.repository.find_best_match(existing_pin, prereleases)
except NoCandidateFound:
return self.repository.find_best_match(ireq, prereleases)
else:
project, version, _ = as_tuple(existing_pin)
return make_install_requirement(project, version, ireq)
else:
return self.repository.find_best_match(ireq, prereleases)

Expand Down
1 change: 0 additions & 1 deletion tests/test_cli_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -1620,7 +1620,6 @@ def test_preserve_compiled_prerelease_version(pip_conf, runner):
assert "small-fake-a==0.3b1" in out.stderr.splitlines()


@pytest.mark.xfail
def test_ignore_compiled_unavailable_version(pip_conf, runner):
with open("requirements.in", "w") as req_in:
req_in.write("small-fake-a")
Expand Down

0 comments on commit d1a0651

Please sign in to comment.