o Ecn@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'de dede(ddfddZ)dee(efdede fddZ* d(de dee ddfddZ+d)de de,ddfd d!Z-ded"e(d#e(de(fd$d%Z.ded"e(d#e(de(fd&d'Z/Gd(d)d)eZ0eed*d+d,d,d-d.Z1ed/efe2d0<eed1d2d3dd4d5Z3ed/efe2d2<eed6d7d3dd8d5Z4ed/efe2d7<eed9d:d;d3ded5Z5ed/efe2d<<eed=d>d?d@ddAd5Z6ed/efe2d?<eedBdCd3ddDd5Z7ed/efe2dC<eedEdFdGd3dHd.Z8ed/efe2dG<eedIdJdKd@ddLd5Z9ed/efe2dK<eedMdNdOe:e;dPdQdRed/efe2dX<eed\d]d3dd^d5Z?ed/efe2d]<eed_d`dadbdcddZ@ed/efe2d`<eededfdgdhdiddZAed/efe2df<eedjdkdldmdndodpdqZBed/efe2dm<defdrdsZCee0dtdudYdYdvdwZDed/efe2du<ee0dxdydYddYdzd{ZEed/efe2dy<eed|d}d~dde!jFddZGed/efe2d<defddZHeeddd3ddd5ZIed/efe2d<defddZJdefddZKdefddZLdefddZMdefddZNdede(d#e(de ddf ddZOee0ddddddYdedeOdd ZPed/efe2d<de dedefddZQdede(d#e(de ddf ddZRdede(d#e(de ddf ddZSdefddZTdefddZUeedddddddZVed/efe2d<d#e(deeeWd/fee(ffddZXdede(d#e(de ddf ddZYeeddddeYdade dd ZZed/efe2d<eeddddddZ[ed/efe2d<eedddddddZ\ed/efe2d<de ddfddZ]de de#fddÄZ^defddńZ_ee0ddeddYddɍZ`ed/efe2d<ded"e(d#e(de ddf dd˄Zaeedddeadd΍Zbed/efe2d<eedddd3ddd5Zced/efe2d<eeddd3dd.Zded/efe2d<eedddddd5Zeed/efe2d<ded"e(d#e(de ddf dd߄Zfeeddd3ddd5Zgee2d<eedddefdedZhee2d<eeddddddZied/efe2d<eeddddddZjed/efe2d<eeddddddZked/efe2d<eedd3dddZled/efe2d<eedd3dddZmed/efe2d<eeddd3ddd5Zned/efe2d<dede(d#e(de ddf ddZoeedddeodddZped/efe2d<eeddd3ddd5Zqed/efe2d<ee0ddYdYdddZred/efe2d <de ddfd d Zsee0d d dddddZted/efe2d<eeddd3ddd5Zued/efe2d<eeddddggdddZved/efe2d<eeddddgdd gd!dZwed/efe2d"<d#e1e3e4e5e6e8e9e>e?e@eAeBeCeKeDeEe`ebene7euevewgd$Zxee(efe2d%<d&eGeHeIeJgd$Zyee(efe2d'<dS(*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)AnyCallableDictOptionalTuplecanonicalize_name)ConfigOptionParser) BAR_TYPES) CommandError)USER_CACHE_DIRget_src_prefix) FormatControl)PyPI) TargetPython) STRONG_HASHES) strtoboolparseroptionmsgreturncCs0|d|}td|}||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)textwrapZfilljoinspliterror)rrrr#O/opt/alt/python310/lib/python3.10/site-packages/pip/_internal/cli/cmdoptions.pyraise_option_error"s r%groupcCs,t||d}|dD]}||q |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&rZ option_grouprr#r#r$make_option_group0s r*r( check_optionscs`dur|dtdttffdd }gd}tt||r.|j}|tjddd dSdS) 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. Nnrcs t|dSN)getattr)r,r+r#r$getnameH z+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+r0namesZcontrolr#r/r$check_install_build_global<s  r>F check_targetcCsjt|j|j|j|jg}ttdh}|j|ko|j }|r$|r$t d|r/|r1|j s3t ddSdSdS)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) r8python_version platformsabisimplementationrsetr:ignore_dependenciesrZ target_dir)r(r?Zdist_restriction_setZ binary_onlyZsdist_dependencies_allowedr#r#r$check_dist_restrictionVs*  rFoptvaluecCs tj|Sr-)ospath expanduserrrGrHr#r#r$_path_option_check~r1rMcCst|Sr-rrLr#r#r$_package_name_option_checksrNc@s0eZdZejdZejZeed<eed<dS) PipOption)rJ package_namerPrJN) __name__ __module__ __qualname__rZTYPESZ TYPE_CHECKERcopyrNrMr#r#r#r$rOs    rOz-hz--helphelpz Show help.)destactionrU.help_z--debug debug_mode store_truezbLet unhandled exceptions propagate outside the main subroutine, instead of logging them to stderr.rVrWdefaultrUz --isolated isolated_modezSRun pip in an isolated mode, ignoring environment variables and user configuration.z--require-virtualenvz--require-venvZ require_venvrequire_virtualenvz-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_barchoiceZonz*Specify type of progress to be displayed [|z] (default: %default))rVtypechoicesr\rUz--logz --log-filez --local-loglogrJz Path to a verbose appending log.)rVmetavarrgrUz --no-inputno_inputzDisable prompting for input.z--proxyproxyr7z/src". The default for global installs is "/src".)rVrgrjr\rWrrUsrcrcCs t||jS)zGet a format_control object.)r.rV)rrr#r#r$_get_format_controls rcC"t|j|}t||j|jdSr-)rrrhandle_mutual_excludes no_binary only_binaryrrrHrZexistingr#r#r$_handle_no_binary rcCrr-)rrrrrrrr#r#r$_handle_only_binaryrrc C$ttt}tdddtd|ddS)Nz --no-binaryr:rr7avDo 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.rVrWrrgr\rU)rrDrrr:r#r#r$rrc Cr)Nz --only-binaryr:rr7aKDo 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.r)rrDrrrr#r#r$rrrz --platformrAplatformrzzOnly 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.rcCs|sdS|d}t|dkrdSt|dkr+|d}t|dkr+|d|ddg}ztdd |D}W|dfStyCYd Sw) 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. )NN.)r#z'at most three version parts are allowedrNcss|]}t|VqdSr-)ro).0partr#r#r$ 8sz*_convert_python_version..)r#z$each version part must be an integer)r!lentuple ValueError)rHparts version_infor#r#r$_convert_python_version"s     rcCs:t|\}}|durd||}t|||d||j_dS)z3 Handle a provided --python-version value. Nz(invalid --python-version value: {!r}: {}rr)rformatr%rr@)rrrHrrZ 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). )rVrjrWrrgr\rUz--implementationrCzOnly 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--abirBZabiaLOnly 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_optscCs4|t|t|t|tdSr-)r)rAr@rCrB)rr#r#r$add_target_python_optionss   rcCst|j|j|j|jd}|S)N)rAZpy_version_inforBrC)rrAr@rBrC)r(Z target_pythonr#r#r$make_target_pythonsrcCstddddddS)Nz--prefer-binary prefer_binaryrZFz8Prefer older binary packages over newer source packages.r[r{r#r#r#r$rsrz --cache-dir cache_dirzStore the cache data in .)rVr\rjrgrUc CsX|dur&zt|Wnty%}zt||t|dWYd}~nd}~wwd|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. NrF)rrr%r7rr)rrGrHrexcr#r#r$_handle_no_cache_dirs   rz--no-cache-dirzDisable the cache.)rVrWrrUno_cachez --no-depsz--no-dependenciesrEz#Don't install package dependencies.no_depsz--ignore-requires-pythonignore_requires_pythonz'Ignore the Requires-Python information.z--no-build-isolationZbuild_isolationZ store_falseTzDisable isolation when building a modern source distribution. Build dependencies specified by PEP 518 must be already installed if this option is used.no_build_isolationcCs&|dur d}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. rF)r%r use_pep517)rrGrHrrr#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)rVrWrr\rU no_use_pep517z--install-optionr4a"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.)rVrWrjrUz--build-optionr2z9Extra arguments to be supplied to 'setup.py bdist_wheel'.)rVrjrWrUz--global-optionr3zcExtra 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.)rWr\rUno_cleanz--prezYInclude pre-release and development versions. By default, pip only finds stable versions.prez--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.cCs|jjsi|j_z |dd\}}Wnty#|d|Ynw|tvr4|d|dt|jj|g |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 setdefaultrz)rrrHrZalgoZdigestr#r#r$_handle_merge_hash[s"  rz--hashrstringzgVerify that the package's archive matches this hash before installing. Example: --hash=sha256:abcdef...)rVrWrrgrUhashz--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).)rVrgrWrU list_pathcCs"|jr |js |jrtddSdS)Nz2Cannot combine '--path' with '--user' or '--local')rJuserZlocalr)r(r#r#r$check_list_path_optionsrz --excludeZexcludespackagerPz)Exclude specified package from the output)rVrWrjrgrU list_excludez--no-python-version-warningno_python_version_warningz>Silence deprecation warnings for upcoming unsupported Pythons.z --use-featureZfeatures_enabledZfeature)z 2020-resolverz fast-depsz in-tree-buildzboolrFrMrNrOrX__annotations__rYr]r^r_rarbrclistkeysr rdrirkrlrnrqrtr|r}Z simple_urlr~rrrrrrrrrrrrrrrArorrr@rCrBrrrrrrrrrrrrr4r2r3rrrrrrrrrrrrrrr#r#r#r$s              (                         &