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 --generate-hashes when hashes are computed from files #1540

Merged
merged 2 commits into from
Apr 4, 2022
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
4 changes: 4 additions & 0 deletions piptools/repositories/pypi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Empty file.
7 changes: 7 additions & 0 deletions tests/test_repository_pypi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down