diff --git a/piptools/resolver.py b/piptools/resolver.py index bb85a20e6..09263c74b 100644 --- a/piptools/resolver.py +++ b/piptools/resolver.py @@ -751,7 +751,14 @@ def _get_install_requirement_from_candidate( # Prepare pinned install requirement. Copy it from candidate's install # requirement so that it could be mutated later. - pinned_ireq = copy_install_requirement(ireq) + pinned_ireq = copy_install_requirement( + template=ireq, + # The link this candidate "originates" from. This is different + # from ``ireq.link`` when the link is found in the wheel cache. + # ``ireq.link`` would point to the wheel cache, while this points + # to the found remote link (e.g. from pypi.org). + link=candidate.source_link, + ) # Canonicalize name assert ireq.name is not None