3 ign@s` UdZddlZddlZddlZddlmZddlmZmZm Z m Z m Z ddlm Z ddl mZmZmZmZmZddlmZddlmZdd lmZdd lmZdd lmZmZdd lmZdd l m!Z!ddl"m#Z#ddl$m%Z%ddl&m'Z'e ee(ddddZ)ee(efee dddZ*de ee ddddZ+de e,ddddZ-ee(e(e(ddd Z.ee(e(e(dd!d"Z/Gd#d$d$eZ0eed%d&d'd'd(d)Z1ed*ef1eed+d,d-dd.d/Z2ed*ef2eed0d1d-dd2d/Z3ed*ef3eed3d4d5d-ded/Z4ed*ef4eed6d7d8d9dd:d/Z5ed*ef5eed;dd?d@d-dAd)Z7ed*ef7eedBdCdDd9ddEd/Z8ed*ef8eedFdGdHe9ej:dIdJdKj;ej:dLdMZed*ef>eedXdYdZd[d\d]Z?ed*ef?eed^d_d`dadbd]Z@ed*ef@eedcdddedfdgdhdidjZAed*efAedkdldmZBee0dndodRdRdpdqZCed*efCee0drdsdRddRdtduZDed*efDeedvdwdxdydze!jEd{d|ZFed*efFedkd}d~ZGeeddd-ddd/ZHed*efHedkddZIedkddZJedkddZKedkddZLedkddZMee(e(e ddddZNee0ddddddRdedeNdd ZOed*efOe eedddZPee(e(e ddddZQee(e(e ddddZRedkddZSedkddZTeedddddddZUed*efUe(eeeVd*fee(fdddZWee(e(e ddddZXeeddddeXdZde dd ZYed*efYeedddddd|ZZed*efZeedddddddZ[ed*ef[e ddddZ\e e#dddZ]edkddZ^ee0ddeddRddčZ_ed*ef_ee(e(e ddŜddDŽZ`eeddde`ddʍZaed*efaeedddd-ddd/Zbed*efbeeddd-dd)Zced*efceedddddd/Zded*efdee(e(e ddŜdd؄Zeeeddd-ddd/ZfefeedddeededݍZgegeeddddddZhed*efheeddddddZied*efieeddddddZjed*efjeedd-dddZked*efkeedd-dddZled*efleeddd-ddd/Zmed*efmee(e(e ddddZneedddendddZoed*efoeeddd-ddd/Zped*efpee0ddRdRdddZqed*efqe ddddZree0dddddddZsed*efseeddd-dd d/Zted*efteed d d dgd ddgddZued*efueeddd dgddgddZved*efvde1e2e3e4e5e7e8e=e>e?e@eAeBeJeCeDe_eaeme6eteuevgdZwee(efwdeFeGeHeIgdZxee(efxdS(aC shared options and groups The principle here is to define options once, but *not* instantiate them globally. One reason being that options with action='append' can carry state between parses. pip parses general options twice internally, and shouldn't pass on state. To be consistent, all options will follow this design. N)partial) SUPPRESS_HELPOption OptionGroup OptionParserValues)dedent)AnyCallableDictOptionalTuple)canonicalize_name)ConfigOptionParser) BAR_TYPES) CommandError)USER_CACHE_DIRget_src_prefix) FormatControl)PyPI) TargetPython) STRONG_HASHES) strtobool)parseroptionmsgreturncCs0|d|}tjdj|j}|j|dS)z Raise an option parsing error using parser.error(). Args: parser: an OptionParser instance. option: an Option instance. msg: the error text. z error:  N)textwrapfilljoinspliterror)rrrr#;/tmp/pip-build-88gy_88q/pip/pip/_internal/cli/cmdoptions.pyraise_option_error"s r%)grouprrcCs0t||d}x|dD]}|j|qW|S)z Return an OptionGroup object group -- assumed to be dict with 'name' and 'options' keys parser -- an optparse Parser nameoptions)r add_option)r&r option_grouprr#r#r$make_option_group0sr+)r( check_optionsrcs\dkr |tttdfdd }dddg}tt||rX|j}|jtjdd d dS) zDisable wheels if per-setup.py call options are set. :param options: The OptionParser options to update. :param check_options: The options to check, if not supplied defaults to options. N)nrcs t|dS)N)getattr)r-)r,r#r$getnameHsz+check_install_build_global..getname build_optionsglobal_optionsinstall_optionszbDisabling all use of wheels due to the use of --build-option / --global-option / --install-option.) stacklevel) strr r anymapformat_controlZdisallow_binarieswarningswarn)r(r,r/namescontrolr#)r,r$check_install_build_global<s  r=F)r( check_targetrcCsdt|j|j|j|jg}ttdh}|j|ko6|j }|rH|rHt d|r`|r`|j r`t ddS)zFunction for determining if custom platform options are allowed. :param options: The OptionParser options. :param check_target: Whether or not to check if --target is being used. z:all:zWhen restricting platform and interpreter constraints using --python-version, --platform, --abi, or --implementation, either --no-deps must be set, or --only-binary=:all: must be set and --no-binary must not be set (or must be set to :none:).zQCan not use any platform or abi specific options unless installing via '--target'N) r6python_version platformsabisimplementationrsetr8ignore_dependenciesr target_dir)r(r>dist_restriction_set binary_onlyZsdist_dependencies_allowedr#r#r$check_dist_restrictionVs  rH)roptvaluercCs tjj|S)N)ospath expanduser)rrIrJr#r#r$_path_option_check~srNcCst|S)N)r)rrIrJr#r#r$_package_name_option_checksrOc@s0eZdZejdZejjZeed<eed<dS) PipOptionrL package_nameN)rLrQ) __name__ __module__ __qualname__rTYPES TYPE_CHECKERcopyrOrNr#r#r#r$rPs  rPz-hz--helphelpz Show help.)destactionrX.z--debug debug_mode store_truezbLet unhandled exceptions propagate outside the main subroutine, instead of logging them to stderr.)rYrZdefaultrXz --isolated isolated_modezSRun pip in an isolated mode, ignoring environment variables and user configuration.z--require-virtualenvz--require-venv require_venvz-vz --verboseverbosecountzDGive more output. Option is additive, and can be used up to 3 times.z --no-colorno_colorzSuppress colored output.z-Vz --versionversionzShow version and exit.z-qz--quietquietzGive less output. Option is additive, and can be used up to 3 times (corresponding to WARNING, ERROR, and CRITICAL logging levels).z--progress-bar progress_barchoiceonz*Specify type of progress to be displayed [|z] (default: %default))rYtypechoicesr]rXz--logz --log-filez --local-loglogrLz Path to a verbose appending log.)rYmetavarrirXz --no-inputno_inputzDisable prompting for input.z--proxyproxyr5z/src". The default for global installs is "/src".)rYrirlr]rZrrX)rrrcCs t||jS)zGet a format_control object.)r.rY)rrr#r#r$_get_format_controlsrcCs"t|j|}tj||j|jdS)N)rrrhandle_mutual_excludes no_binary only_binary)rrrJrexistingr#r#r$_handle_no_binarys  rcCs"t|j|}tj||j|jdS)N)rrrrrr)rrrJrrr#r#r$_handle_only_binarys  rc Cs$ttt}tdddtd|ddS)Nz --no-binaryr8rr5avDo not use binary packages. Can be supplied multiple times, and each time adds to the existing value. Accepts either ":all:" to disable all binary packages, ":none:" to empty the set (notice the colons), or one or more package names with commas between them (no colons). Note that some packages are tricky to compile and may fail to install when this option is used on them.)rYrZrrir]rX)rrCrr)r8r#r#r$rsrc Cs$ttt}tdddtd|ddS)Nz --only-binaryr8rr5aKDo not use source packages. Can be supplied multiple times, and each time adds to the existing value. Accepts either ":all:" to disable all source packages, ":none:" to empty the set, or one or more package names with commas between them. Packages without binary distributions will fail to install when this option is used on them.)rYrZrrir]rX)rrCrr)r8r#r#r$rsrz --platformr@platformr}zOnly use wheels compatible with . Defaults to the platform of the running system. Use this option multiple times to specify multiple platforms supported by the target interpreter.)rYrlrZr]rX)rJrc Cs|sd S|jd}t|dkr&fdfSt|dkrZ|d}t|dkrZ|d|ddg}ytdd|D}Wntk rfd fSX|dfS) z Convert a version string like "3", "37", or "3.7.3" into a tuple of ints. :return: A 2-tuple (version_info, error_msg), where `error_msg` is non-None if and only if there was a parsing error. N.z'at most three version parts are allowedrcss|]}t|VqdS)N)rq).0partr#r#r$ 8sz*_convert_python_version..z$each version part must be an integer)NN)r!lentuple ValueError)rJparts version_infor#r#r$_convert_python_version"s     rcCs:t|\}}|dk r.dj||}t|||d||j_dS)z3 Handle a provided --python-version value. Nz(invalid --python-version value: {!r}: {})rr)rformatr%rr?)rrrJrrZ error_msgrr#r#r$_handle_python_version?s rz--python-versionr?a The Python interpreter version to use for wheel and "Requires-Python" compatibility checks. Defaults to a version derived from the running interpreter. The version can be specified using up to three dot-separated integers (e.g. "3" for 3.0.0, "3.7" for 3.7.0, or "3.7.3"). A major-minor version can also be given as a string without dots (e.g. "37" for 3.7.0). )rYrlrZrrir]rXz--implementationrBzOnly use wheels compatible with Python implementation , e.g. 'pp', 'jy', 'cp', or 'ip'. If not specified, then the current interpreter implementation is used. Use 'py' to force implementation-agnostic wheels.z--abirAabiaLOnly use wheels compatible with Python abi , e.g. 'pypy_41'. If not specified, then the current interpreter abi tag is used. Use this option multiple times to specify multiple abis supported by the target interpreter. Generally you will need to specify --implementation, --platform, and --python-version when using this option.)cmd_optsrcCs4|jt|jt|jt|jtdS)N)r)r@r?rBrA)rr#r#r$add_target_python_optionss   r)r(rcCst|j|j|j|jd}|S)N)r@Zpy_version_inforArB)rr@r?rArB)r(Z target_pythonr#r#r$make_target_pythons  rcCstddddddS)Nz--prefer-binary prefer_binaryr\Fz8Prefer older binary packages over newer source packages.)rYrZr]rX)rr#r#r#r$rs rz --cache-dir cache_dirzStore the cache data in .)rYr]rlrirX)rrIrJrrcCsV|dk rJy t|Wn4tk rH}zt||t|dWYdd}~XnXd|j_dS)z Process a value provided for the --no-cache-dir option. This is an optparse.Option callback for the --no-cache-dir option. N)rrF)rrr%r5rr)rrIrJrexcr#r#r$_handle_no_cache_dirs  $ rz--no-cache-dirzDisable the cache.)rYrZrrXz --no-depsz--no-dependenciesrDz#Don't install package dependencies.z--ignore-requires-pythonignore_requires_pythonz'Ignore the Requires-Python information.z--no-build-isolationZbuild_isolation store_falseTzDisable isolation when building a modern source distribution. Build dependencies specified by PEP 518 must be already installed if this option is used.cCs&|dk rd}t|||dd|j_dS)z Process a value provided for the --no-use-pep517 option. This is an optparse.Option callback for the no_use_pep517 option. Na0A value was passed for --no-use-pep517, probably using either the PIP_NO_USE_PEP517 environment variable or the "no-use-pep517" config file option. Use an appropriate value of the PIP_USE_PEP517 environment variable or the "use-pep517" config file option instead. )rrF)r%r use_pep517)rrIrJrrr#r#r$_handle_no_use_pep517s rz --use-pep517rz^Use PEP 517 for building source distributions (use --no-use-pep517 to force legacy behaviour).z--no-use-pep517)rYrZrr]rXz--install-optionr2r(a"Extra arguments to be supplied to the setup.py install command (use like --install-option="--install-scripts=/usr/local/bin"). Use multiple --install-option options to pass multiple options to setup.py install. If you are using an option with a directory path, be sure to use absolute path.)rYrZrlrXz--build-optionr0z9Extra arguments to be supplied to 'setup.py bdist_wheel'.)rYrlrZrXz--global-optionr1zcExtra global options to be supplied to the setup.py call before the install or bdist_wheel command.z --no-cleanz!Don't clean up build directories.)rZr]rXz--prezYInclude pre-release and development versions. By default, pip only finds stable versions.z--disable-pip-version-checkdisable_pip_version_checkz{Don't periodically check PyPI to determine whether a new version of pip is available for download. Implied with --no-index.c Cs|jjsi|j_y|jdd\}}Wn$tk rH|jdj|YnX|tkrj|jdj|djt|jjj|gj |dS)zkGiven a value spelled "algo:digest", append the digest to a list pointed to in a dict by the algo name.:rzTArguments to {} must be a hash name followed by a value, like --hash=sha256:abcde...z&Allowed hash algorithms for {} are {}.z, N) rhashesr!rr"rrr setdefaultr})rrrJralgodigestr#r#r$_handle_merge_hash[srz--hashrstringzgVerify that the package's archive matches this hash before installing. Example: --hash=sha256:abcdef...)rYrZrrirXz--require-hashesrequire_hasheszRequire a hash to check each requirement against, for repeatable installs. This option is implied when any package in a requirements file has a --hash option.z--pathz^Restrict to the specified installation path for listing packages (can be used multiple times).)rYrirZrXcCs|jr|js|jrtddS)Nz2Cannot combine '--path' with '--user' or '--local')rLuserlocalr)r(r#r#r$check_list_path_optionsrz --excludeZexcludespackagerQz)Exclude specified package from the output)rYrZrlrirXz--no-python-version-warningno_python_version_warningz>Silence deprecation warnings for upcoming unsupported Pythons.z --use-featureZfeatures_enabledZfeaturez 2020-resolverz fast-depsz in-tree-buildzs8            (  &      $