diff --git a/piptools/repositories/pypi.py b/piptools/repositories/pypi.py index 7ec300c7a..2d7d247c6 100644 --- a/piptools/repositories/pypi.py +++ b/piptools/repositories/pypi.py @@ -436,6 +436,10 @@ def _wheel_support_index_min(self: Wheel, tags: List[Tag]) -> int: Wheel.support_index_min = _wheel_support_index_min self._available_candidates_cache = {} + # If we don't clear this cache then it can contain results from an + # earlier call when allow_all_wheels wasn't active. See GH-1532 + self.finder.find_all_candidates.cache_clear() + try: yield finally: diff --git a/tests/test_data/minimal_wheels/small-fake-multi-arch-0.1.tar.gz b/tests/test_data/minimal_wheels/small-fake-multi-arch-0.1.tar.gz new file mode 100644 index 000000000..e69de29bb diff --git a/tests/test_repository_pypi.py b/tests/test_repository_pypi.py index 078a181e9..3e9e4592d 100644 --- a/tests/test_repository_pypi.py +++ b/tests/test_repository_pypi.py @@ -15,9 +15,16 @@ def test_generate_hashes_all_platforms(capsys, pip_conf, from_line, pypi_reposit "sha256:8d4d131cd05338e09f461ad784297efea3652e542c5fabe04a62358429a6175e", "sha256:ad05e1371eb99f257ca00f791b755deb22e752393eb8e75bc01d651715b02ea9", "sha256:24afa5b317b302f356fd3fc3b1cfb0aad114d509cf635ea9566052424191b944", + "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", } ireq = from_line("small-fake-multi-arch==0.1") + + # pip caches the candidates for the current system, which means + # allow_all_wheels won't have the desired effect unless the cache is + # cleared. See GH-1532 + assert pypi_repository.get_hashes(ireq) < expected + with pypi_repository.allow_all_wheels(): assert pypi_repository.get_hashes(ireq) == expected captured = capsys.readouterr()