Edit File by line
/home/barbar84/www/wp-conte.../plugins/sujqvwi/ShExBy/shex_roo.../lib/python3..../site-pac.../pip
File: cmdoptions.py
"""
[0] Fix | Delete
shared options and groups
[1] Fix | Delete
[2] Fix | Delete
The principle here is to define options once, but *not* instantiate them
[3] Fix | Delete
globally. One reason being that options with action='append' can carry state
[4] Fix | Delete
between parses. pip parses general options twice internally, and shouldn't
[5] Fix | Delete
pass on state. To be consistent, all options will follow this design.
[6] Fix | Delete
[7] Fix | Delete
"""
[8] Fix | Delete
from __future__ import absolute_import
[9] Fix | Delete
[10] Fix | Delete
from functools import partial
[11] Fix | Delete
from optparse import OptionGroup, SUPPRESS_HELP, Option
[12] Fix | Delete
import warnings
[13] Fix | Delete
[14] Fix | Delete
from pip.index import (
[15] Fix | Delete
FormatControl, fmt_ctl_handle_mutual_exclude, fmt_ctl_no_binary,
[16] Fix | Delete
fmt_ctl_no_use_wheel)
[17] Fix | Delete
from pip.models import PyPI
[18] Fix | Delete
from pip.locations import USER_CACHE_DIR, src_prefix
[19] Fix | Delete
from pip.utils.hashes import STRONG_HASHES
[20] Fix | Delete
[21] Fix | Delete
[22] Fix | Delete
def make_option_group(group, parser):
[23] Fix | Delete
"""
[24] Fix | Delete
Return an OptionGroup object
[25] Fix | Delete
group -- assumed to be dict with 'name' and 'options' keys
[26] Fix | Delete
parser -- an optparse Parser
[27] Fix | Delete
"""
[28] Fix | Delete
option_group = OptionGroup(parser, group['name'])
[29] Fix | Delete
for option in group['options']:
[30] Fix | Delete
option_group.add_option(option())
[31] Fix | Delete
return option_group
[32] Fix | Delete
[33] Fix | Delete
[34] Fix | Delete
def resolve_wheel_no_use_binary(options):
[35] Fix | Delete
if not options.use_wheel:
[36] Fix | Delete
control = options.format_control
[37] Fix | Delete
fmt_ctl_no_use_wheel(control)
[38] Fix | Delete
[39] Fix | Delete
[40] Fix | Delete
def check_install_build_global(options, check_options=None):
[41] Fix | Delete
"""Disable wheels if per-setup.py call options are set.
[42] Fix | Delete
[43] Fix | Delete
:param options: The OptionParser options to update.
[44] Fix | Delete
:param check_options: The options to check, if not supplied defaults to
[45] Fix | Delete
options.
[46] Fix | Delete
"""
[47] Fix | Delete
if check_options is None:
[48] Fix | Delete
check_options = options
[49] Fix | Delete
[50] Fix | Delete
def getname(n):
[51] Fix | Delete
return getattr(check_options, n, None)
[52] Fix | Delete
names = ["build_options", "global_options", "install_options"]
[53] Fix | Delete
if any(map(getname, names)):
[54] Fix | Delete
control = options.format_control
[55] Fix | Delete
fmt_ctl_no_binary(control)
[56] Fix | Delete
warnings.warn(
[57] Fix | Delete
'Disabling all use of wheels due to the use of --build-options '
[58] Fix | Delete
'/ --global-options / --install-options.', stacklevel=2)
[59] Fix | Delete
[60] Fix | Delete
[61] Fix | Delete
###########
[62] Fix | Delete
# options #
[63] Fix | Delete
###########
[64] Fix | Delete
[65] Fix | Delete
help_ = partial(
[66] Fix | Delete
Option,
[67] Fix | Delete
'-h', '--help',
[68] Fix | Delete
dest='help',
[69] Fix | Delete
action='help',
[70] Fix | Delete
help='Show help.')
[71] Fix | Delete
[72] Fix | Delete
isolated_mode = partial(
[73] Fix | Delete
Option,
[74] Fix | Delete
"--isolated",
[75] Fix | Delete
dest="isolated_mode",
[76] Fix | Delete
action="store_true",
[77] Fix | Delete
default=False,
[78] Fix | Delete
help=(
[79] Fix | Delete
"Run pip in an isolated mode, ignoring environment variables and user "
[80] Fix | Delete
"configuration."
[81] Fix | Delete
),
[82] Fix | Delete
)
[83] Fix | Delete
[84] Fix | Delete
require_virtualenv = partial(
[85] Fix | Delete
Option,
[86] Fix | Delete
# Run only if inside a virtualenv, bail if not.
[87] Fix | Delete
'--require-virtualenv', '--require-venv',
[88] Fix | Delete
dest='require_venv',
[89] Fix | Delete
action='store_true',
[90] Fix | Delete
default=False,
[91] Fix | Delete
help=SUPPRESS_HELP)
[92] Fix | Delete
[93] Fix | Delete
verbose = partial(
[94] Fix | Delete
Option,
[95] Fix | Delete
'-v', '--verbose',
[96] Fix | Delete
dest='verbose',
[97] Fix | Delete
action='count',
[98] Fix | Delete
default=0,
[99] Fix | Delete
help='Give more output. Option is additive, and can be used up to 3 times.'
[100] Fix | Delete
)
[101] Fix | Delete
[102] Fix | Delete
version = partial(
[103] Fix | Delete
Option,
[104] Fix | Delete
'-V', '--version',
[105] Fix | Delete
dest='version',
[106] Fix | Delete
action='store_true',
[107] Fix | Delete
help='Show version and exit.')
[108] Fix | Delete
[109] Fix | Delete
quiet = partial(
[110] Fix | Delete
Option,
[111] Fix | Delete
'-q', '--quiet',
[112] Fix | Delete
dest='quiet',
[113] Fix | Delete
action='count',
[114] Fix | Delete
default=0,
[115] Fix | Delete
help=('Give less output. Option is additive, and can be used up to 3'
[116] Fix | Delete
' times (corresponding to WARNING, ERROR, and CRITICAL logging'
[117] Fix | Delete
' levels).')
[118] Fix | Delete
)
[119] Fix | Delete
[120] Fix | Delete
log = partial(
[121] Fix | Delete
Option,
[122] Fix | Delete
"--log", "--log-file", "--local-log",
[123] Fix | Delete
dest="log",
[124] Fix | Delete
metavar="path",
[125] Fix | Delete
help="Path to a verbose appending log."
[126] Fix | Delete
)
[127] Fix | Delete
[128] Fix | Delete
no_input = partial(
[129] Fix | Delete
Option,
[130] Fix | Delete
# Don't ask for input
[131] Fix | Delete
'--no-input',
[132] Fix | Delete
dest='no_input',
[133] Fix | Delete
action='store_true',
[134] Fix | Delete
default=False,
[135] Fix | Delete
help=SUPPRESS_HELP)
[136] Fix | Delete
[137] Fix | Delete
proxy = partial(
[138] Fix | Delete
Option,
[139] Fix | Delete
'--proxy',
[140] Fix | Delete
dest='proxy',
[141] Fix | Delete
type='str',
[142] Fix | Delete
default='',
[143] Fix | Delete
help="Specify a proxy in the form [user:passwd@]proxy.server:port.")
[144] Fix | Delete
[145] Fix | Delete
retries = partial(
[146] Fix | Delete
Option,
[147] Fix | Delete
'--retries',
[148] Fix | Delete
dest='retries',
[149] Fix | Delete
type='int',
[150] Fix | Delete
default=5,
[151] Fix | Delete
help="Maximum number of retries each connection should attempt "
[152] Fix | Delete
"(default %default times).")
[153] Fix | Delete
[154] Fix | Delete
timeout = partial(
[155] Fix | Delete
Option,
[156] Fix | Delete
'--timeout', '--default-timeout',
[157] Fix | Delete
metavar='sec',
[158] Fix | Delete
dest='timeout',
[159] Fix | Delete
type='float',
[160] Fix | Delete
default=15,
[161] Fix | Delete
help='Set the socket timeout (default %default seconds).')
[162] Fix | Delete
[163] Fix | Delete
default_vcs = partial(
[164] Fix | Delete
Option,
[165] Fix | Delete
# The default version control system for editables, e.g. 'svn'
[166] Fix | Delete
'--default-vcs',
[167] Fix | Delete
dest='default_vcs',
[168] Fix | Delete
type='str',
[169] Fix | Delete
default='',
[170] Fix | Delete
help=SUPPRESS_HELP)
[171] Fix | Delete
[172] Fix | Delete
skip_requirements_regex = partial(
[173] Fix | Delete
Option,
[174] Fix | Delete
# A regex to be used to skip requirements
[175] Fix | Delete
'--skip-requirements-regex',
[176] Fix | Delete
dest='skip_requirements_regex',
[177] Fix | Delete
type='str',
[178] Fix | Delete
default='',
[179] Fix | Delete
help=SUPPRESS_HELP)
[180] Fix | Delete
[181] Fix | Delete
[182] Fix | Delete
def exists_action():
[183] Fix | Delete
return Option(
[184] Fix | Delete
# Option when path already exist
[185] Fix | Delete
'--exists-action',
[186] Fix | Delete
dest='exists_action',
[187] Fix | Delete
type='choice',
[188] Fix | Delete
choices=['s', 'i', 'w', 'b', 'a'],
[189] Fix | Delete
default=[],
[190] Fix | Delete
action='append',
[191] Fix | Delete
metavar='action',
[192] Fix | Delete
help="Default action when a path already exists: "
[193] Fix | Delete
"(s)witch, (i)gnore, (w)ipe, (b)ackup, (a)bort.")
[194] Fix | Delete
[195] Fix | Delete
[196] Fix | Delete
cert = partial(
[197] Fix | Delete
Option,
[198] Fix | Delete
'--cert',
[199] Fix | Delete
dest='cert',
[200] Fix | Delete
type='str',
[201] Fix | Delete
metavar='path',
[202] Fix | Delete
help="Path to alternate CA bundle.")
[203] Fix | Delete
[204] Fix | Delete
client_cert = partial(
[205] Fix | Delete
Option,
[206] Fix | Delete
'--client-cert',
[207] Fix | Delete
dest='client_cert',
[208] Fix | Delete
type='str',
[209] Fix | Delete
default=None,
[210] Fix | Delete
metavar='path',
[211] Fix | Delete
help="Path to SSL client certificate, a single file containing the "
[212] Fix | Delete
"private key and the certificate in PEM format.")
[213] Fix | Delete
[214] Fix | Delete
index_url = partial(
[215] Fix | Delete
Option,
[216] Fix | Delete
'-i', '--index-url', '--pypi-url',
[217] Fix | Delete
dest='index_url',
[218] Fix | Delete
metavar='URL',
[219] Fix | Delete
default=PyPI.simple_url,
[220] Fix | Delete
help="Base URL of Python Package Index (default %default). "
[221] Fix | Delete
"This should point to a repository compliant with PEP 503 "
[222] Fix | Delete
"(the simple repository API) or a local directory laid out "
[223] Fix | Delete
"in the same format.")
[224] Fix | Delete
[225] Fix | Delete
[226] Fix | Delete
def extra_index_url():
[227] Fix | Delete
return Option(
[228] Fix | Delete
'--extra-index-url',
[229] Fix | Delete
dest='extra_index_urls',
[230] Fix | Delete
metavar='URL',
[231] Fix | Delete
action='append',
[232] Fix | Delete
default=[],
[233] Fix | Delete
help="Extra URLs of package indexes to use in addition to "
[234] Fix | Delete
"--index-url. Should follow the same rules as "
[235] Fix | Delete
"--index-url."
[236] Fix | Delete
)
[237] Fix | Delete
[238] Fix | Delete
[239] Fix | Delete
no_index = partial(
[240] Fix | Delete
Option,
[241] Fix | Delete
'--no-index',
[242] Fix | Delete
dest='no_index',
[243] Fix | Delete
action='store_true',
[244] Fix | Delete
default=False,
[245] Fix | Delete
help='Ignore package index (only looking at --find-links URLs instead).')
[246] Fix | Delete
[247] Fix | Delete
[248] Fix | Delete
def find_links():
[249] Fix | Delete
return Option(
[250] Fix | Delete
'-f', '--find-links',
[251] Fix | Delete
dest='find_links',
[252] Fix | Delete
action='append',
[253] Fix | Delete
default=[],
[254] Fix | Delete
metavar='url',
[255] Fix | Delete
help="If a url or path to an html file, then parse for links to "
[256] Fix | Delete
"archives. If a local path or file:// url that's a directory, "
[257] Fix | Delete
"then look for archives in the directory listing.")
[258] Fix | Delete
[259] Fix | Delete
[260] Fix | Delete
def allow_external():
[261] Fix | Delete
return Option(
[262] Fix | Delete
"--allow-external",
[263] Fix | Delete
dest="allow_external",
[264] Fix | Delete
action="append",
[265] Fix | Delete
default=[],
[266] Fix | Delete
metavar="PACKAGE",
[267] Fix | Delete
help=SUPPRESS_HELP,
[268] Fix | Delete
)
[269] Fix | Delete
[270] Fix | Delete
[271] Fix | Delete
allow_all_external = partial(
[272] Fix | Delete
Option,
[273] Fix | Delete
"--allow-all-external",
[274] Fix | Delete
dest="allow_all_external",
[275] Fix | Delete
action="store_true",
[276] Fix | Delete
default=False,
[277] Fix | Delete
help=SUPPRESS_HELP,
[278] Fix | Delete
)
[279] Fix | Delete
[280] Fix | Delete
[281] Fix | Delete
def trusted_host():
[282] Fix | Delete
return Option(
[283] Fix | Delete
"--trusted-host",
[284] Fix | Delete
dest="trusted_hosts",
[285] Fix | Delete
action="append",
[286] Fix | Delete
metavar="HOSTNAME",
[287] Fix | Delete
default=[],
[288] Fix | Delete
help="Mark this host as trusted, even though it does not have valid "
[289] Fix | Delete
"or any HTTPS.",
[290] Fix | Delete
)
[291] Fix | Delete
[292] Fix | Delete
[293] Fix | Delete
# Remove after 7.0
[294] Fix | Delete
no_allow_external = partial(
[295] Fix | Delete
Option,
[296] Fix | Delete
"--no-allow-external",
[297] Fix | Delete
dest="allow_all_external",
[298] Fix | Delete
action="store_false",
[299] Fix | Delete
default=False,
[300] Fix | Delete
help=SUPPRESS_HELP,
[301] Fix | Delete
)
[302] Fix | Delete
[303] Fix | Delete
[304] Fix | Delete
# Remove --allow-insecure after 7.0
[305] Fix | Delete
def allow_unsafe():
[306] Fix | Delete
return Option(
[307] Fix | Delete
"--allow-unverified", "--allow-insecure",
[308] Fix | Delete
dest="allow_unverified",
[309] Fix | Delete
action="append",
[310] Fix | Delete
default=[],
[311] Fix | Delete
metavar="PACKAGE",
[312] Fix | Delete
help=SUPPRESS_HELP,
[313] Fix | Delete
)
[314] Fix | Delete
[315] Fix | Delete
# Remove after 7.0
[316] Fix | Delete
no_allow_unsafe = partial(
[317] Fix | Delete
Option,
[318] Fix | Delete
"--no-allow-insecure",
[319] Fix | Delete
dest="allow_all_insecure",
[320] Fix | Delete
action="store_false",
[321] Fix | Delete
default=False,
[322] Fix | Delete
help=SUPPRESS_HELP
[323] Fix | Delete
)
[324] Fix | Delete
[325] Fix | Delete
# Remove after 1.5
[326] Fix | Delete
process_dependency_links = partial(
[327] Fix | Delete
Option,
[328] Fix | Delete
"--process-dependency-links",
[329] Fix | Delete
dest="process_dependency_links",
[330] Fix | Delete
action="store_true",
[331] Fix | Delete
default=False,
[332] Fix | Delete
help="Enable the processing of dependency links.",
[333] Fix | Delete
)
[334] Fix | Delete
[335] Fix | Delete
[336] Fix | Delete
def constraints():
[337] Fix | Delete
return Option(
[338] Fix | Delete
'-c', '--constraint',
[339] Fix | Delete
dest='constraints',
[340] Fix | Delete
action='append',
[341] Fix | Delete
default=[],
[342] Fix | Delete
metavar='file',
[343] Fix | Delete
help='Constrain versions using the given constraints file. '
[344] Fix | Delete
'This option can be used multiple times.')
[345] Fix | Delete
[346] Fix | Delete
[347] Fix | Delete
def requirements():
[348] Fix | Delete
return Option(
[349] Fix | Delete
'-r', '--requirement',
[350] Fix | Delete
dest='requirements',
[351] Fix | Delete
action='append',
[352] Fix | Delete
default=[],
[353] Fix | Delete
metavar='file',
[354] Fix | Delete
help='Install from the given requirements file. '
[355] Fix | Delete
'This option can be used multiple times.')
[356] Fix | Delete
[357] Fix | Delete
[358] Fix | Delete
def editable():
[359] Fix | Delete
return Option(
[360] Fix | Delete
'-e', '--editable',
[361] Fix | Delete
dest='editables',
[362] Fix | Delete
action='append',
[363] Fix | Delete
default=[],
[364] Fix | Delete
metavar='path/url',
[365] Fix | Delete
help=('Install a project in editable mode (i.e. setuptools '
[366] Fix | Delete
'"develop mode") from a local project path or a VCS url.'),
[367] Fix | Delete
)
[368] Fix | Delete
[369] Fix | Delete
src = partial(
[370] Fix | Delete
Option,
[371] Fix | Delete
'--src', '--source', '--source-dir', '--source-directory',
[372] Fix | Delete
dest='src_dir',
[373] Fix | Delete
metavar='dir',
[374] Fix | Delete
default=src_prefix,
[375] Fix | Delete
help='Directory to check out editable projects into. '
[376] Fix | Delete
'The default in a virtualenv is "<venv path>/src". '
[377] Fix | Delete
'The default for global installs is "<current dir>/src".'
[378] Fix | Delete
)
[379] Fix | Delete
[380] Fix | Delete
# XXX: deprecated, remove in 9.0
[381] Fix | Delete
use_wheel = partial(
[382] Fix | Delete
Option,
[383] Fix | Delete
'--use-wheel',
[384] Fix | Delete
dest='use_wheel',
[385] Fix | Delete
action='store_true',
[386] Fix | Delete
default=True,
[387] Fix | Delete
help=SUPPRESS_HELP,
[388] Fix | Delete
)
[389] Fix | Delete
[390] Fix | Delete
# XXX: deprecated, remove in 9.0
[391] Fix | Delete
no_use_wheel = partial(
[392] Fix | Delete
Option,
[393] Fix | Delete
'--no-use-wheel',
[394] Fix | Delete
dest='use_wheel',
[395] Fix | Delete
action='store_false',
[396] Fix | Delete
default=True,
[397] Fix | Delete
help=('Do not Find and prefer wheel archives when searching indexes and '
[398] Fix | Delete
'find-links locations. DEPRECATED in favour of --no-binary.'),
[399] Fix | Delete
)
[400] Fix | Delete
[401] Fix | Delete
[402] Fix | Delete
def _get_format_control(values, option):
[403] Fix | Delete
"""Get a format_control object."""
[404] Fix | Delete
return getattr(values, option.dest)
[405] Fix | Delete
[406] Fix | Delete
[407] Fix | Delete
def _handle_no_binary(option, opt_str, value, parser):
[408] Fix | Delete
existing = getattr(parser.values, option.dest)
[409] Fix | Delete
fmt_ctl_handle_mutual_exclude(
[410] Fix | Delete
value, existing.no_binary, existing.only_binary)
[411] Fix | Delete
[412] Fix | Delete
[413] Fix | Delete
def _handle_only_binary(option, opt_str, value, parser):
[414] Fix | Delete
existing = getattr(parser.values, option.dest)
[415] Fix | Delete
fmt_ctl_handle_mutual_exclude(
[416] Fix | Delete
value, existing.only_binary, existing.no_binary)
[417] Fix | Delete
[418] Fix | Delete
[419] Fix | Delete
def no_binary():
[420] Fix | Delete
return Option(
[421] Fix | Delete
"--no-binary", dest="format_control", action="callback",
[422] Fix | Delete
callback=_handle_no_binary, type="str",
[423] Fix | Delete
default=FormatControl(set(), set()),
[424] Fix | Delete
help="Do not use binary packages. Can be supplied multiple times, and "
[425] Fix | Delete
"each time adds to the existing value. Accepts either :all: to "
[426] Fix | Delete
"disable all binary packages, :none: to empty the set, or one or "
[427] Fix | Delete
"more package names with commas between them. Note that some "
[428] Fix | Delete
"packages are tricky to compile and may fail to install when "
[429] Fix | Delete
"this option is used on them.")
[430] Fix | Delete
[431] Fix | Delete
[432] Fix | Delete
def only_binary():
[433] Fix | Delete
return Option(
[434] Fix | Delete
"--only-binary", dest="format_control", action="callback",
[435] Fix | Delete
callback=_handle_only_binary, type="str",
[436] Fix | Delete
default=FormatControl(set(), set()),
[437] Fix | Delete
help="Do not use source packages. Can be supplied multiple times, and "
[438] Fix | Delete
"each time adds to the existing value. Accepts either :all: to "
[439] Fix | Delete
"disable all source packages, :none: to empty the set, or one or "
[440] Fix | Delete
"more package names with commas between them. Packages without "
[441] Fix | Delete
"binary distributions will fail to install when this option is "
[442] Fix | Delete
"used on them.")
[443] Fix | Delete
[444] Fix | Delete
[445] Fix | Delete
cache_dir = partial(
[446] Fix | Delete
Option,
[447] Fix | Delete
"--cache-dir",
[448] Fix | Delete
dest="cache_dir",
[449] Fix | Delete
default=USER_CACHE_DIR,
[450] Fix | Delete
metavar="dir",
[451] Fix | Delete
help="Store the cache data in <dir>."
[452] Fix | Delete
)
[453] Fix | Delete
[454] Fix | Delete
no_cache = partial(
[455] Fix | Delete
Option,
[456] Fix | Delete
"--no-cache-dir",
[457] Fix | Delete
dest="cache_dir",
[458] Fix | Delete
action="store_false",
[459] Fix | Delete
help="Disable the cache.",
[460] Fix | Delete
)
[461] Fix | Delete
[462] Fix | Delete
no_deps = partial(
[463] Fix | Delete
Option,
[464] Fix | Delete
'--no-deps', '--no-dependencies',
[465] Fix | Delete
dest='ignore_dependencies',
[466] Fix | Delete
action='store_true',
[467] Fix | Delete
default=False,
[468] Fix | Delete
help="Don't install package dependencies.")
[469] Fix | Delete
[470] Fix | Delete
build_dir = partial(
[471] Fix | Delete
Option,
[472] Fix | Delete
'-b', '--build', '--build-dir', '--build-directory',
[473] Fix | Delete
dest='build_dir',
[474] Fix | Delete
metavar='dir',
[475] Fix | Delete
help='Directory to unpack packages into and build in.'
[476] Fix | Delete
)
[477] Fix | Delete
[478] Fix | Delete
ignore_requires_python = partial(
[479] Fix | Delete
Option,
[480] Fix | Delete
'--ignore-requires-python',
[481] Fix | Delete
dest='ignore_requires_python',
[482] Fix | Delete
action='store_true',
[483] Fix | Delete
help='Ignore the Requires-Python information.')
[484] Fix | Delete
[485] Fix | Delete
install_options = partial(
[486] Fix | Delete
Option,
[487] Fix | Delete
'--install-option',
[488] Fix | Delete
dest='install_options',
[489] Fix | Delete
action='append',
[490] Fix | Delete
metavar='options',
[491] Fix | Delete
help="Extra arguments to be supplied to the setup.py install "
[492] Fix | Delete
"command (use like --install-option=\"--install-scripts=/usr/local/"
[493] Fix | Delete
"bin\"). Use multiple --install-option options to pass multiple "
[494] Fix | Delete
"options to setup.py install. If you are using an option with a "
[495] Fix | Delete
"directory path, be sure to use absolute path.")
[496] Fix | Delete
[497] Fix | Delete
global_options = partial(
[498] Fix | Delete
Option,
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function