summaryrefslogtreecommitdiff
path: root/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/cmdoptions.py
diff options
context:
space:
mode:
Diffstat (limited to 'venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/cmdoptions.py')
-rw-r--r--venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/cmdoptions.py609
1 files changed, 0 insertions, 609 deletions
diff --git a/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/cmdoptions.py b/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/cmdoptions.py
deleted file mode 100644
index 58854e3..0000000
--- a/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/cmdoptions.py
+++ /dev/null
@@ -1,609 +0,0 @@
1"""
2shared options and groups
3
4The principle here is to define options once, but *not* instantiate them
5globally. One reason being that options with action='append' can carry state
6between parses. pip parses general options twice internally, and shouldn't
7pass on state. To be consistent, all options will follow this design.
8
9"""
10from __future__ import absolute_import
11
12import warnings
13from functools import partial
14from optparse import SUPPRESS_HELP, Option, OptionGroup
15
16from pip._internal.index import (
17 FormatControl, fmt_ctl_handle_mutual_exclude, fmt_ctl_no_binary,
18)
19from pip._internal.locations import USER_CACHE_DIR, src_prefix
20from pip._internal.models import PyPI
21from pip._internal.utils.hashes import STRONG_HASHES
22from pip._internal.utils.typing import MYPY_CHECK_RUNNING
23from pip._internal.utils.ui import BAR_TYPES
24
25if MYPY_CHECK_RUNNING:
26 from typing import Any
27
28
29def make_option_group(group, parser):
30 """
31 Return an OptionGroup object
32 group -- assumed to be dict with 'name' and 'options' keys
33 parser -- an optparse Parser
34 """
35 option_group = OptionGroup(parser, group['name'])
36 for option in group['options']:
37 option_group.add_option(option())
38 return option_group
39
40
41def check_install_build_global(options, check_options=None):
42 """Disable wheels if per-setup.py call options are set.
43
44 :param options: The OptionParser options to update.
45 :param check_options: The options to check, if not supplied defaults to
46 options.
47 """
48 if check_options is None:
49 check_options = options
50
51 def getname(n):
52 return getattr(check_options, n, None)
53 names = ["build_options", "global_options", "install_options"]
54 if any(map(getname, names)):
55 control = options.format_control
56 fmt_ctl_no_binary(control)
57 warnings.warn(
58 'Disabling all use of wheels due to the use of --build-options '
59 '/ --global-options / --install-options.', stacklevel=2,
60 )
61
62
63###########
64# options #
65###########
66
67help_ = partial(
68 Option,
69 '-h', '--help',
70 dest='help',
71 action='help',
72 help='Show help.',
73) # type: Any
74
75isolated_mode = partial(
76 Option,
77 "--isolated",
78 dest="isolated_mode",
79 action="store_true",
80 default=False,
81 help=(
82 "Run pip in an isolated mode, ignoring environment variables and user "
83 "configuration."
84 ),
85)
86
87require_virtualenv = partial(
88 Option,
89 # Run only if inside a virtualenv, bail if not.
90 '--require-virtualenv', '--require-venv',
91 dest='require_venv',
92 action='store_true',
93 default=False,
94 help=SUPPRESS_HELP
95) # type: Any
96
97verbose = partial(
98 Option,
99 '-v', '--verbose',
100 dest='verbose',
101 action='count',
102 default=0,
103 help='Give more output. Option is additive, and can be used up to 3 times.'
104)
105
106no_color = partial(
107 Option,
108 '--no-color',
109 dest='no_color',
110 action='store_true',
111 default=False,
112 help="Suppress colored output",
113)
114
115version = partial(
116 Option,
117 '-V', '--version',
118 dest='version',
119 action='store_true',
120 help='Show version and exit.',
121) # type: Any
122
123quiet = partial(
124 Option,
125 '-q', '--quiet',
126 dest='quiet',
127 action='count',
128 default=0,
129 help=(
130 'Give less output. Option is additive, and can be used up to 3'
131 ' times (corresponding to WARNING, ERROR, and CRITICAL logging'
132 ' levels).'
133 ),
134) # type: Any
135
136progress_bar = partial(
137 Option,
138 '--progress-bar',
139 dest='progress_bar',
140 type='choice',
141 choices=list(BAR_TYPES.keys()),
142 default='on',
143 help=(
144 'Specify type of progress to be displayed [' +
145 '|'.join(BAR_TYPES.keys()) + '] (default: %default)'
146 ),
147) # type: Any
148
149log = partial(
150 Option,
151 "--log", "--log-file", "--local-log",
152 dest="log",
153 metavar="path",
154 help="Path to a verbose appending log."
155) # type: Any
156
157no_input = partial(
158 Option,
159 # Don't ask for input
160 '--no-input',
161 dest='no_input',
162 action='store_true',
163 default=False,
164 help=SUPPRESS_HELP
165) # type: Any
166
167proxy = partial(
168 Option,
169 '--proxy',
170 dest='proxy',
171 type='str',
172 default='',
173 help="Specify a proxy in the form [user:passwd@]proxy.server:port."
174) # type: Any
175
176retries = partial(
177 Option,
178 '--retries',
179 dest='retries',
180 type='int',
181 default=5,
182 help="Maximum number of retries each connection should attempt "
183 "(default %default times).",
184) # type: Any
185
186timeout = partial(
187 Option,
188 '--timeout', '--default-timeout',
189 metavar='sec',
190 dest='timeout',
191 type='float',
192 default=15,
193 help='Set the socket timeout (default %default seconds).',
194) # type: Any
195
196skip_requirements_regex = partial(
197 Option,
198 # A regex to be used to skip requirements
199 '--skip-requirements-regex',
200 dest='skip_requirements_regex',
201 type='str',
202 default='',
203 help=SUPPRESS_HELP,
204) # type: Any
205
206
207def exists_action():
208 return Option(
209 # Option when path already exist
210 '--exists-action',
211 dest='exists_action',
212 type='choice',
213 choices=['s', 'i', 'w', 'b', 'a'],
214 default=[],
215 action='append',
216 metavar='action',
217 help="Default action when a path already exists: "
218 "(s)witch, (i)gnore, (w)ipe, (b)ackup, (a)bort).",
219 )
220
221
222cert = partial(
223 Option,
224 '--cert',
225 dest='cert',
226 type='str',
227 metavar='path',
228 help="Path to alternate CA bundle.",
229) # type: Any
230
231client_cert = partial(
232 Option,
233 '--client-cert',
234 dest='client_cert',
235 type='str',
236 default=None,
237 metavar='path',
238 help="Path to SSL client certificate, a single file containing the "
239 "private key and the certificate in PEM format.",
240) # type: Any
241
242index_url = partial(
243 Option,
244 '-i', '--index-url', '--pypi-url',
245 dest='index_url',
246 metavar='URL',
247 default=PyPI.simple_url,
248 help="Base URL of Python Package Index (default %default). "
249 "This should point to a repository compliant with PEP 503 "
250 "(the simple repository API) or a local directory laid out "
251 "in the same format.",
252) # type: Any
253
254
255def extra_index_url():
256 return Option(
257 '--extra-index-url',
258 dest='extra_index_urls',
259 metavar='URL',
260 action='append',
261 default=[],
262 help="Extra URLs of package indexes to use in addition to "
263 "--index-url. Should follow the same rules as "
264 "--index-url.",
265 )
266
267
268no_index = partial(
269 Option,
270 '--no-index',
271 dest='no_index',
272 action='store_true',
273 default=False,
274 help='Ignore package index (only looking at --find-links URLs instead).',
275) # type: Any
276
277
278def find_links():
279 return Option(
280 '-f', '--find-links',
281 dest='find_links',
282 action='append',
283 default=[],
284 metavar='url',
285 help="If a url or path to an html file, then parse for links to "
286 "archives. If a local path or file:// url that's a directory, "
287 "then look for archives in the directory listing.",
288 )
289
290
291def trusted_host():
292 return Option(
293 "--trusted-host",
294 dest="trusted_hosts",
295 action="append",
296 metavar="HOSTNAME",
297 default=[],
298 help="Mark this host as trusted, even though it does not have valid "
299 "or any HTTPS.",
300 )
301
302
303# Remove after 1.5
304process_dependency_links = partial(
305 Option,
306 "--process-dependency-links",
307 dest="process_dependency_links",
308 action="store_true",
309 default=False,
310 help="Enable the processing of dependency links.",
311) # type: Any
312
313
314def constraints():
315 return Option(
316 '-c', '--constraint',
317 dest='constraints',
318 action='append',
319 default=[],
320 metavar='file',
321 help='Constrain versions using the given constraints file. '
322 'This option can be used multiple times.'
323 )
324
325
326def requirements():
327 return Option(
328 '-r', '--requirement',
329 dest='requirements',
330 action='append',
331 default=[],
332 metavar='file',
333 help='Install from the given requirements file. '
334 'This option can be used multiple times.'
335 )
336
337
338def editable():
339 return Option(
340 '-e', '--editable',
341 dest='editables',
342 action='append',
343 default=[],
344 metavar='path/url',
345 help=('Install a project in editable mode (i.e. setuptools '
346 '"develop mode") from a local project path or a VCS url.'),
347 )
348
349
350src = partial(
351 Option,
352 '--src', '--source', '--source-dir', '--source-directory',
353 dest='src_dir',
354 metavar='dir',
355 default=src_prefix,
356 help='Directory to check out editable projects into. '
357 'The default in a virtualenv is "<venv path>/src". '
358 'The default for global installs is "<current dir>/src".'
359) # type: Any
360
361
362def _get_format_control(values, option):
363 """Get a format_control object."""
364 return getattr(values, option.dest)
365
366
367def _handle_no_binary(option, opt_str, value, parser):
368 existing = getattr(parser.values, option.dest)
369 fmt_ctl_handle_mutual_exclude(
370 value, existing.no_binary, existing.only_binary,
371 )
372
373
374def _handle_only_binary(option, opt_str, value, parser):
375 existing = getattr(parser.values, option.dest)
376 fmt_ctl_handle_mutual_exclude(
377 value, existing.only_binary, existing.no_binary,
378 )
379
380
381def no_binary():
382 return Option(
383 "--no-binary", dest="format_control", action="callback",
384 callback=_handle_no_binary, type="str",
385 default=FormatControl(set(), set()),
386 help="Do not use binary packages. Can be supplied multiple times, and "
387 "each time adds to the existing value. Accepts either :all: to "
388 "disable all binary packages, :none: to empty the set, or one or "
389 "more package names with commas between them. Note that some "
390 "packages are tricky to compile and may fail to install when "
391 "this option is used on them.",
392 )
393
394
395def only_binary():
396 return Option(
397 "--only-binary", dest="format_control", action="callback",
398 callback=_handle_only_binary, type="str",
399 default=FormatControl(set(), set()),
400 help="Do not use source packages. Can be supplied multiple times, and "
401 "each time adds to the existing value. Accepts either :all: to "
402 "disable all source packages, :none: to empty the set, or one or "
403 "more package names with commas between them. Packages without "
404 "binary distributions will fail to install when this option is "
405 "used on them.",
406 )
407
408
409cache_dir = partial(
410 Option,
411 "--cache-dir",
412 dest="cache_dir",
413 default=USER_CACHE_DIR,
414 metavar="dir",
415 help="Store the cache data in <dir>."
416)
417
418no_cache = partial(
419 Option,
420 "--no-cache-dir",
421 dest="cache_dir",
422 action="store_false",
423 help="Disable the cache.",
424)
425
426no_deps = partial(
427 Option,
428 '--no-deps', '--no-dependencies',
429 dest='ignore_dependencies',
430 action='store_true',
431 default=False,
432 help="Don't install package dependencies.",
433) # type: Any
434
435build_dir = partial(
436 Option,
437 '-b', '--build', '--build-dir', '--build-directory',
438 dest='build_dir',
439 metavar='dir',
440 help='Directory to unpack packages into and build in. Note that '
441 'an initial build still takes place in a temporary directory. '
442 'The location of temporary directories can be controlled by setting '
443 'the TMPDIR environment variable (TEMP on Windows) appropriately. '
444 'When passed, build directories are not cleaned in case of failures.'
445) # type: Any
446
447ignore_requires_python = partial(
448 Option,
449 '--ignore-requires-python',
450 dest='ignore_requires_python',
451 action='store_true',
452 help='Ignore the Requires-Python information.'
453) # type: Any
454
455no_build_isolation = partial(
456 Option,
457 '--no-build-isolation',
458 dest='build_isolation',
459 action='store_false',
460 default=True,
461 help='Disable isolation when building a modern source distribution. '
462 'Build dependencies specified by PEP 518 must be already installed '
463 'if this option is used.'
464) # type: Any
465
466install_options = partial(
467 Option,
468 '--install-option',
469 dest='install_options',
470 action='append',
471 metavar='options',
472 help="Extra arguments to be supplied to the setup.py install "
473 "command (use like --install-option=\"--install-scripts=/usr/local/"
474 "bin\"). Use multiple --install-option options to pass multiple "
475 "options to setup.py install. If you are using an option with a "
476 "directory path, be sure to use absolute path.",
477) # type: Any
478
479global_options = partial(
480 Option,
481 '--global-option',
482 dest='global_options',
483 action='append',
484 metavar='options',
485 help="Extra global options to be supplied to the setup.py "
486 "call before the install command.",
487) # type: Any
488
489no_clean = partial(
490 Option,
491 '--no-clean',
492 action='store_true',
493 default=False,
494 help="Don't clean up build directories)."
495) # type: Any
496
497pre = partial(
498 Option,
499 '--pre',
500 action='store_true',
501 default=False,
502 help="Include pre-release and development versions. By default, "
503 "pip only finds stable versions.",
504) # type: Any
505
506disable_pip_version_check = partial(
507 Option,
508 "--disable-pip-version-check",
509 dest="disable_pip_version_check",
510 action="store_true",
511 default=False,
512 help="Don't periodically check PyPI to determine whether a new version "
513 "of pip is available for download. Implied with --no-index.",
514) # type: Any
515
516
517# Deprecated, Remove later
518always_unzip = partial(
519 Option,
520 '-Z', '--always-unzip',
521 dest='always_unzip',
522 action='store_true',
523 help=SUPPRESS_HELP,
524) # type: Any
525
526
527def _merge_hash(option, opt_str, value, parser):
528 """Given a value spelled "algo:digest", append the digest to a list
529 pointed to in a dict by the algo name."""
530 if not parser.values.hashes:
531 parser.values.hashes = {}
532 try:
533 algo, digest = value.split(':', 1)
534 except ValueError:
535 parser.error('Arguments to %s must be a hash name '
536 'followed by a value, like --hash=sha256:abcde...' %
537 opt_str)
538 if algo not in STRONG_HASHES:
539 parser.error('Allowed hash algorithms for %s are %s.' %
540 (opt_str, ', '.join(STRONG_HASHES)))
541 parser.values.hashes.setdefault(algo, []).append(digest)
542
543
544hash = partial(
545 Option,
546 '--hash',
547 # Hash values eventually end up in InstallRequirement.hashes due to
548 # __dict__ copying in process_line().
549 dest='hashes',
550 action='callback',
551 callback=_merge_hash,
552 type='string',
553 help="Verify that the package's archive matches this "
554 'hash before installing. Example: --hash=sha256:abcdef...',
555) # type: Any
556
557
558require_hashes = partial(
559 Option,
560 '--require-hashes',
561 dest='require_hashes',
562 action='store_true',
563 default=False,
564 help='Require a hash to check each requirement against, for '
565 'repeatable installs. This option is implied when any package in a '
566 'requirements file has a --hash option.',
567) # type: Any
568
569
570##########
571# groups #
572##########
573
574general_group = {
575 'name': 'General Options',
576 'options': [
577 help_,
578 isolated_mode,
579 require_virtualenv,
580 verbose,
581 version,
582 quiet,
583 log,
584 no_input,
585 proxy,
586 retries,
587 timeout,
588 skip_requirements_regex,
589 exists_action,
590 trusted_host,
591 cert,
592 client_cert,
593 cache_dir,
594 no_cache,
595 disable_pip_version_check,
596 no_color,
597 ]
598}
599
600index_group = {
601 'name': 'Package Index Options',
602 'options': [
603 index_url,
604 extra_index_url,
605 no_index,
606 find_links,
607 process_dependency_links,
608 ]
609}