|
8 | 8 | import mimetypes |
9 | 9 | import os |
10 | 10 | import shutil |
11 | | -import sys |
12 | 11 |
|
13 | 12 | from pip._vendor import requests |
14 | 13 | from pip._vendor.six import PY2 |
|
29 | 28 | from pip._internal.utils.hashes import MissingHashes |
30 | 29 | from pip._internal.utils.logging import indent_log |
31 | 30 | from pip._internal.utils.misc import ( |
32 | | - ask_path_exists, |
33 | | - backup_dir, |
34 | 31 | display_path, |
35 | 32 | hide_url, |
36 | 33 | path_to_display, |
@@ -102,37 +99,6 @@ def unpack_vcs_link(link, location): |
102 | 99 | vcs_backend.unpack(location, url=hide_url(link.url)) |
103 | 100 |
|
104 | 101 |
|
105 | | -def _copy_file(filename, location, link): |
106 | | - # type: (str, str, Link) -> None |
107 | | - copy = True |
108 | | - download_location = os.path.join(location, link.filename) |
109 | | - if os.path.exists(download_location): |
110 | | - response = ask_path_exists( |
111 | | - 'The file {} exists. (i)gnore, (w)ipe, (b)ackup, (a)abort'.format( |
112 | | - display_path(download_location) |
113 | | - ), |
114 | | - ('i', 'w', 'b', 'a'), |
115 | | - ) |
116 | | - if response == 'i': |
117 | | - copy = False |
118 | | - elif response == 'w': |
119 | | - logger.warning('Deleting %s', display_path(download_location)) |
120 | | - os.remove(download_location) |
121 | | - elif response == 'b': |
122 | | - dest_file = backup_dir(download_location) |
123 | | - logger.warning( |
124 | | - 'Backing up %s to %s', |
125 | | - display_path(download_location), |
126 | | - display_path(dest_file), |
127 | | - ) |
128 | | - shutil.move(download_location, dest_file) |
129 | | - elif response == 'a': |
130 | | - sys.exit(-1) |
131 | | - if copy: |
132 | | - shutil.copy(filename, download_location) |
133 | | - logger.info('Saved %s', display_path(download_location)) |
134 | | - |
135 | | - |
136 | 102 | class File(object): |
137 | 103 | def __init__(self, path, content_type): |
138 | 104 | # type: (str, str) -> None |
@@ -513,10 +479,15 @@ def prepare_linked_requirement( |
513 | 479 | if download_dir: |
514 | 480 | if link.is_existing_dir(): |
515 | 481 | logger.info('Link is a directory, ignoring download_dir') |
516 | | - elif local_file and not os.path.exists( |
517 | | - os.path.join(download_dir, link.filename) |
518 | | - ): |
519 | | - _copy_file(local_file.path, download_dir, link) |
| 482 | + elif local_file: |
| 483 | + download_location = os.path.join( |
| 484 | + download_dir, link.filename |
| 485 | + ) |
| 486 | + if not os.path.exists(download_location): |
| 487 | + shutil.copy(local_file.path, download_location) |
| 488 | + logger.info( |
| 489 | + 'Saved %s', display_path(download_location) |
| 490 | + ) |
520 | 491 |
|
521 | 492 | if self._download_should_save: |
522 | 493 | # Make a .zip of the source_dir we already created. |
|
0 commit comments