def prepare_linked_requirement(<EOL>self,<EOL>req,  <EOL>session,  <EOL>finder,  <EOL>upgrade_allowed,  <EOL>require_hashes  <EOL>):<EOL>
<EOL>if req.link and req.link.scheme == '<STR_LIT:file>':<EOL><INDENT>path = url_to_path(req.link.url)<EOL>logger.info('<STR_LIT>', display_path(path))<EOL><DEDENT>else:<EOL><INDENT>logger.info('<STR_LIT>', req)<EOL><DEDENT>with indent_log():<EOL><INDENT>req.ensure_has_source_dir(self.build_dir)<EOL>if os.path.exists(os.path.join(req.source_dir, '<STR_LIT>')):<EOL><INDENT>rmtree(req.source_dir)<EOL><DEDENT>req.populate_link(finder, upgrade_allowed, require_hashes)<EOL>assert req.link<EOL>link = req.link<EOL>if require_hashes:<EOL><INDENT>if is_vcs_url(link):<EOL><INDENT>raise VcsHashUnsupported()<EOL><DEDENT>elif is_file_url(link) and is_dir_url(link):<EOL><INDENT>raise DirectoryUrlHashUnsupported()<EOL><DEDENT>if not req.original_link and not req.is_pinned:<EOL><INDENT>raise HashUnpinned()<EOL><DEDENT><DEDENT>hashes = req.hashes(trust_internet=not require_hashes)<EOL>if require_hashes and not hashes:<EOL><INDENT>hashes = MissingHashes()<EOL><DEDENT>try:<EOL><INDENT>download_dir = self.download_dir<EOL>autodelete_unpacked = True<EOL>if req.link.is_wheel and self.wheel_download_dir:<EOL><INDENT>download_dir = self.wheel_download_dir<EOL><DEDENT>if req.link.is_wheel:<EOL><INDENT>if download_dir:<EOL><INDENT>autodelete_unpacked = True<EOL><DEDENT>else:<EOL><INDENT>autodelete_unpacked = False<EOL><DEDENT><DEDENT>unpack_url(<EOL>req.link, req.source_dir,<EOL>download_dir, autodelete_unpacked,<EOL>session=session, hashes=hashes,<EOL>progress_bar=self.progress_bar<EOL>)<EOL><DEDENT>except requests.HTTPError as exc:<EOL><INDENT>logger.critical(<EOL>'<STR_LIT>',<EOL>req,<EOL>exc,<EOL>)<EOL>raise InstallationError(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>' %<EOL>(req, exc, req.link)<EOL>)<EOL><DEDENT>abstract_dist = make_abstract_dist(req)<EOL>with self.req_tracker.track(req):<EOL><INDENT>abstract_dist.prep_for_dist(finder, self.build_isolation)<EOL><DEDENT>if self._download_should_save:<EOL><INDENT>if req.link.scheme in vcs.all_schemes:<EOL><INDENT>req.archive(self.download_dir)<EOL><DEDENT><DEDENT><DEDENT>return abstract_dist<EOL>
Prepare a requirement that would be obtained from req.link