Skip to content

Commit ce9ddbb

Browse files
committed
Move download file copying out of unpacking functions
Now our "unpacking" functions aren't also for sometimes populating the download directory.
1 parent 5c90145 commit ce9ddbb

File tree

1 file changed

+5
-23
lines changed

1 file changed

+5
-23
lines changed

src/pip/_internal/operations/prepare.py

+5-23
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,6 @@ def unpack_http_url(
165165
# downloading archives, they have to be unpacked to parse dependencies
166166
unpack_file(from_path, location, content_type)
167167

168-
# a download dir is specified; let's copy the archive there
169-
if download_dir and not os.path.exists(
170-
os.path.join(download_dir, link.filename)
171-
):
172-
_copy_file(from_path, download_dir, link)
173-
174168
return from_path
175169

176170

@@ -223,9 +217,6 @@ def unpack_file_url(
223217
):
224218
# type: (...) -> Optional[str]
225219
"""Unpack link into location.
226-
227-
If download_dir is provided and link points to a file, make a copy
228-
of the link file inside download_dir.
229220
"""
230221
link_path = link.file_path
231222
# If it's a url to a local directory
@@ -261,12 +252,6 @@ def unpack_file_url(
261252
# archives, they have to be unpacked to parse dependencies
262253
unpack_file(from_path, location, content_type)
263254

264-
# a download dir is specified and not already downloaded
265-
if download_dir and not os.path.exists(
266-
os.path.join(download_dir, link.filename)
267-
):
268-
_copy_file(from_path, download_dir, link)
269-
270255
return from_path
271256

272257

@@ -278,14 +263,7 @@ def unpack_url(
278263
hashes=None, # type: Optional[Hashes]
279264
):
280265
# type: (...) -> Optional[str]
281-
"""Unpack link.
282-
If link is a VCS link:
283-
if only_download, export into download_dir and ignore location
284-
else unpack into location
285-
for other types of link:
286-
- unpack into location
287-
- if download_dir, copy the file into download_dir
288-
- if only_download, mark location for deletion
266+
"""Unpack link into location, downloading if required.
289267
290268
:param hashes: A Hashes object, one of whose embedded hashes must match,
291269
or HashMismatch will be raised. If the Hashes is empty, no matches are
@@ -545,6 +523,10 @@ def prepare_linked_requirement(
545523
if download_dir:
546524
if link.is_existing_dir():
547525
logger.info('Link is a directory, ignoring download_dir')
526+
elif local_path and not os.path.exists(
527+
os.path.join(download_dir, link.filename)
528+
):
529+
_copy_file(local_path, download_dir, link)
548530

549531
if self._download_should_save:
550532
# Make a .zip of the source_dir we already created.

0 commit comments

Comments
 (0)