|
25 | 25 | )
|
26 | 26 | from pip._internal.index.package_finder import PackageFinder
|
27 | 27 | from pip._internal.metadata import BaseDistribution
|
| 28 | +from pip._internal.models.direct_url import ArchiveInfo |
28 | 29 | from pip._internal.models.link import Link
|
29 | 30 | from pip._internal.models.wheel import Wheel
|
30 | 31 | from pip._internal.network.download import BatchDownloader, Downloader
|
|
35 | 36 | from pip._internal.network.session import PipSession
|
36 | 37 | from pip._internal.operations.build.build_tracker import BuildTracker
|
37 | 38 | from pip._internal.req.req_install import InstallRequirement
|
| 39 | +from pip._internal.utils.direct_url_helpers import direct_url_from_link |
38 | 40 | from pip._internal.utils.hashes import Hashes, MissingHashes
|
39 | 41 | from pip._internal.utils.logging import indent_log
|
40 |
| -from pip._internal.utils.misc import display_path, hide_url, is_installable_dir |
| 42 | +from pip._internal.utils.misc import ( |
| 43 | + display_path, |
| 44 | + hash_file, |
| 45 | + hide_url, |
| 46 | + is_installable_dir, |
| 47 | +) |
41 | 48 | from pip._internal.utils.temp_dir import TempDirectory
|
42 | 49 | from pip._internal.utils.unpacking import unpack_file
|
43 | 50 | from pip._internal.vcs import vcs
|
@@ -482,10 +489,19 @@ def _prepare_linked_requirement(
|
482 | 489 | hashes.check_against_path(file_path)
|
483 | 490 | local_file = File(file_path, content_type=None)
|
484 | 491 |
|
| 492 | + # TODO handle editable here so we don't have to special case them elsewhere |
| 493 | + req.download_info = direct_url_from_link( |
| 494 | + link, req.source_dir, req.original_link_is_in_wheel_cache |
| 495 | + ) |
| 496 | + |
485 | 497 | # For use in later processing,
|
486 | 498 | # preserve the file path on the requirement.
|
487 | 499 | if local_file:
|
488 | 500 | req.local_file_path = local_file.path
|
| 501 | + assert isinstance(req.download_info.info, ArchiveInfo) |
| 502 | + if not req.download_info.info.hash: |
| 503 | + hash = hash_file(local_file.path)[0].hexdigest() |
| 504 | + req.download_info.info.hash = f"sha256={hash}" |
489 | 505 |
|
490 | 506 | dist = _get_prepared_distribution(
|
491 | 507 | req,
|
|
0 commit comments