diff options
author | Shubham Saini <shubham6405@gmail.com> | 2019-08-05 08:32:33 +0000 |
---|---|---|
committer | Shubham Saini <shubham6405@gmail.com> | 2019-08-05 08:32:33 +0000 |
commit | 227b2d30a8675b44918f9d9ca89b24144a938215 (patch) | |
tree | 9f8e6a28724514b6fdf463a9ab2067a7ef309b72 /venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/commands/download.py | |
parent | 842a8cfbbbdb1f92889d892e4859dbd5d40c5be8 (diff) |
removing venv files
Diffstat (limited to 'venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/commands/download.py')
-rw-r--r-- | venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/commands/download.py | 233 |
1 files changed, 0 insertions, 233 deletions
diff --git a/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/commands/download.py b/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/commands/download.py deleted file mode 100644 index 916a470..0000000 --- a/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/commands/download.py +++ /dev/null | |||
@@ -1,233 +0,0 @@ | |||
1 | from __future__ import absolute_import | ||
2 | |||
3 | import logging | ||
4 | import os | ||
5 | |||
6 | from pip._internal import cmdoptions | ||
7 | from pip._internal.basecommand import RequirementCommand | ||
8 | from pip._internal.exceptions import CommandError | ||
9 | from pip._internal.index import FormatControl | ||
10 | from pip._internal.operations.prepare import RequirementPreparer | ||
11 | from pip._internal.req import RequirementSet | ||
12 | from pip._internal.resolve import Resolver | ||
13 | from pip._internal.utils.filesystem import check_path_owner | ||
14 | from pip._internal.utils.misc import ensure_dir, normalize_path | ||
15 | from pip._internal.utils.temp_dir import TempDirectory | ||
16 | |||
17 | logger = logging.getLogger(__name__) | ||
18 | |||
19 | |||
20 | class DownloadCommand(RequirementCommand): | ||
21 | """ | ||
22 | Download packages from: | ||
23 | |||
24 | - PyPI (and other indexes) using requirement specifiers. | ||
25 | - VCS project urls. | ||
26 | - Local project directories. | ||
27 | - Local or remote source archives. | ||
28 | |||
29 | pip also supports downloading from "requirements files", which provide | ||
30 | an easy way to specify a whole environment to be downloaded. | ||
31 | """ | ||
32 | name = 'download' | ||
33 | |||
34 | usage = """ | ||
35 | %prog [options] <requirement specifier> [package-index-options] ... | ||
36 | %prog [options] -r <requirements file> [package-index-options] ... | ||
37 | %prog [options] <vcs project url> ... | ||
38 | %prog [options] <local project path> ... | ||
39 | %prog [options] <archive url/path> ...""" | ||
40 | |||
41 | summary = 'Download packages.' | ||
42 | |||
43 | def __init__(self, *args, **kw): | ||
44 | super(DownloadCommand, self).__init__(*args, **kw) | ||
45 | |||
46 | cmd_opts = self.cmd_opts | ||
47 | |||
48 | cmd_opts.add_option(cmdoptions.constraints()) | ||
49 | cmd_opts.add_option(cmdoptions.requirements()) | ||
50 | cmd_opts.add_option(cmdoptions.build_dir()) | ||
51 | cmd_opts.add_option(cmdoptions.no_deps()) | ||
52 | cmd_opts.add_option(cmdoptions.global_options()) | ||
53 | cmd_opts.add_option(cmdoptions.no_binary()) | ||
54 | cmd_opts.add_option(cmdoptions.only_binary()) | ||
55 | cmd_opts.add_option(cmdoptions.src()) | ||
56 | cmd_opts.add_option(cmdoptions.pre()) | ||
57 | cmd_opts.add_option(cmdoptions.no_clean()) | ||
58 | cmd_opts.add_option(cmdoptions.require_hashes()) | ||
59 | cmd_opts.add_option(cmdoptions.progress_bar()) | ||
60 | cmd_opts.add_option(cmdoptions.no_build_isolation()) | ||
61 | |||
62 | cmd_opts.add_option( | ||
63 | '-d', '--dest', '--destination-dir', '--destination-directory', | ||
64 | dest='download_dir', | ||
65 | metavar='dir', | ||
66 | default=os.curdir, | ||
67 | help=("Download packages into <dir>."), | ||
68 | ) | ||
69 | |||
70 | cmd_opts.add_option( | ||
71 | '--platform', | ||
72 | dest='platform', | ||
73 | metavar='platform', | ||
74 | default=None, | ||
75 | help=("Only download wheels compatible with <platform>. " | ||
76 | "Defaults to the platform of the running system."), | ||
77 | ) | ||
78 | |||
79 | cmd_opts.add_option( | ||
80 | '--python-version', | ||
81 | dest='python_version', | ||
82 | metavar='python_version', | ||
83 | default=None, | ||
84 | help=("Only download wheels compatible with Python " | ||
85 | "interpreter version <version>. If not specified, then the " | ||
86 | "current system interpreter minor version is used. A major " | ||
87 | "version (e.g. '2') can be specified to match all " | ||
88 | "minor revs of that major version. A minor version " | ||
89 | "(e.g. '34') can also be specified."), | ||
90 | ) | ||
91 | |||
92 | cmd_opts.add_option( | ||
93 | '--implementation', | ||
94 | dest='implementation', | ||
95 | metavar='implementation', | ||
96 | default=None, | ||
97 | help=("Only download wheels compatible with Python " | ||
98 | "implementation <implementation>, e.g. 'pp', 'jy', 'cp', " | ||
99 | " or 'ip'. If not specified, then the current " | ||
100 | "interpreter implementation is used. Use 'py' to force " | ||
101 | "implementation-agnostic wheels."), | ||
102 | ) | ||
103 | |||
104 | cmd_opts.add_option( | ||
105 | '--abi', | ||
106 | dest='abi', | ||
107 | metavar='abi', | ||
108 | default=None, | ||
109 | help=("Only download wheels compatible with Python " | ||
110 | "abi <abi>, e.g. 'pypy_41'. If not specified, then the " | ||
111 | "current interpreter abi tag is used. Generally " | ||
112 | "you will need to specify --implementation, " | ||
113 | "--platform, and --python-version when using " | ||
114 | "this option."), | ||
115 | ) | ||
116 | |||
117 | index_opts = cmdoptions.make_option_group( | ||
118 | cmdoptions.index_group, | ||
119 | self.parser, | ||
120 | ) | ||
121 | |||
122 | self.parser.insert_option_group(0, index_opts) | ||
123 | self.parser.insert_option_group(0, cmd_opts) | ||
124 | |||
125 | def run(self, options, args): | ||
126 | options.ignore_installed = True | ||
127 | # editable doesn't really make sense for `pip download`, but the bowels | ||
128 | # of the RequirementSet code require that property. | ||
129 | options.editables = [] | ||
130 | |||
131 | if options.python_version: | ||
132 | python_versions = [options.python_version] | ||
133 | else: | ||
134 | python_versions = None | ||
135 | |||
136 | dist_restriction_set = any([ | ||
137 | options.python_version, | ||
138 | options.platform, | ||
139 | options.abi, | ||
140 | options.implementation, | ||
141 | ]) | ||
142 | binary_only = FormatControl(set(), {':all:'}) | ||
143 | no_sdist_dependencies = ( | ||
144 | options.format_control != binary_only and | ||
145 | not options.ignore_dependencies | ||
146 | ) | ||
147 | if dist_restriction_set and no_sdist_dependencies: | ||
148 | raise CommandError( | ||
149 | "When restricting platform and interpreter constraints using " | ||
150 | "--python-version, --platform, --abi, or --implementation, " | ||
151 | "either --no-deps must be set, or --only-binary=:all: must be " | ||
152 | "set and --no-binary must not be set (or must be set to " | ||
153 | ":none:)." | ||
154 | ) | ||
155 | |||
156 | options.src_dir = os.path.abspath(options.src_dir) | ||
157 | options.download_dir = normalize_path(options.download_dir) | ||
158 | |||
159 | ensure_dir(options.download_dir) | ||
160 | |||
161 | with self._build_session(options) as session: | ||
162 | finder = self._build_package_finder( | ||
163 | options=options, | ||
164 | session=session, | ||
165 | platform=options.platform, | ||
166 | python_versions=python_versions, | ||
167 | abi=options.abi, | ||
168 | implementation=options.implementation, | ||
169 | ) | ||
170 | build_delete = (not (options.no_clean or options.build_dir)) | ||
171 | if options.cache_dir and not check_path_owner(options.cache_dir): | ||
172 | logger.warning( | ||
173 | "The directory '%s' or its parent directory is not owned " | ||
174 | "by the current user and caching wheels has been " | ||
175 | "disabled. check the permissions and owner of that " | ||
176 | "directory. If executing pip with sudo, you may want " | ||
177 | "sudo's -H flag.", | ||
178 | options.cache_dir, | ||
179 | ) | ||
180 | options.cache_dir = None | ||
181 | |||
182 | with TempDirectory( | ||
183 | options.build_dir, delete=build_delete, kind="download" | ||
184 | ) as directory: | ||
185 | |||
186 | requirement_set = RequirementSet( | ||
187 | require_hashes=options.require_hashes, | ||
188 | ) | ||
189 | self.populate_requirement_set( | ||
190 | requirement_set, | ||
191 | args, | ||
192 | options, | ||
193 | finder, | ||
194 | session, | ||
195 | self.name, | ||
196 | None | ||
197 | ) | ||
198 | |||
199 | preparer = RequirementPreparer( | ||
200 | build_dir=directory.path, | ||
201 | src_dir=options.src_dir, | ||
202 | download_dir=options.download_dir, | ||
203 | wheel_download_dir=None, | ||
204 | progress_bar=options.progress_bar, | ||
205 | build_isolation=options.build_isolation, | ||
206 | ) | ||
207 | |||
208 | resolver = Resolver( | ||
209 | preparer=preparer, | ||
210 | finder=finder, | ||
211 | session=session, | ||
212 | wheel_cache=None, | ||
213 | use_user_site=False, | ||
214 | upgrade_strategy="to-satisfy-only", | ||
215 | force_reinstall=False, | ||
216 | ignore_dependencies=options.ignore_dependencies, | ||
217 | ignore_requires_python=False, | ||
218 | ignore_installed=True, | ||
219 | isolated=options.isolated_mode, | ||
220 | ) | ||
221 | resolver.resolve(requirement_set) | ||
222 | |||
223 | downloaded = ' '.join([ | ||
224 | req.name for req in requirement_set.successfully_downloaded | ||
225 | ]) | ||
226 | if downloaded: | ||
227 | logger.info('Successfully downloaded %s', downloaded) | ||
228 | |||
229 | # Clean up | ||
230 | if not options.no_clean: | ||
231 | requirement_set.cleanup_files() | ||
232 | |||
233 | return requirement_set | ||