U .eh@sdZddlmZddlZddlZddlZddlmZddlm Z ddl m Z m Z m Z ddlmZddlmZdd lmZmZdd lmZdd lmZdd lmZdd lmZddlmZddlmZerddl m!Z!m"Z"m#Z#m$Z$m%Z%ddl m&Z&m'Z'ddl(m)Z)e*e+Z,ddZ-ddZ.dddZ/dddZ0e e dddddd Z1e e d!d"d#dd$d%Z2e e d&d'd(d#de d%Z3e e d)d*d+d,dd-d%Z4e e d.d/d#dd0d%Z5e e d1d2d3d#d4d Z6e e d5d6d7d,dd8d%Z7e e d9d:d;e8e9d:e9d?d@Z;e e dAdBdCdDdEdFdGZe e dPdQdRdSdTdOZ?e e dUdVdWdXdYdZd[d\Z@e e d]d^dLdMe dOZAd_d`ZBe e dadbdLdEdcddZCe e dedfdLddEdgdhZDe e didjdkdldmejEdndoZFdpdqZGe e drdsd#ddtd%ZHdudvZIdwdxZJdydzZKd{d|ZLd}d~ZMe e ddddddeddo ZNddZOddZPddZQddZRddZSe e ddddddoZTddZUddZVe e ddddeVdLdedd ZWe e ddddddoZXe e ddddddoZYddZZddZ[ddZ\e e ddedddZ]ddZ^e e ddde^ddZ_e e dddd#ddd%Z`e e ddddddddGZae e ddd#dd Zbe e dddddd%ZcddĄZde e ddd#ddd%Zee e dddedde dɍZfe e ddddddύZge e ddddddύZhe e dd#dddՍZie e dd#dddՍZje e ddd#ddd%Zke e dddd#e d Zldd߄Zme e dddemdddZne e ddd#ddd%Zoe e ddEddd ZpddZqde1e2e3e4e6e7ee?e@eAeBeJeCeDe]e_eke5gdZrdeFeGeHeIgdZsdS)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. )absolute_importN) strtobool)partial) SUPPRESS_HELPOption OptionGroup)dedent) CommandError)USER_CACHE_DIRget_src_prefix) FormatControl)PyPI) TargetPython) STRONG_HASHES)MYPY_CHECK_RUNNING) BAR_TYPES)AnyCallableDictOptionalTuple) OptionParserValues)ConfigOptionParsercCs.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)formattextwrapZfilljoinspliterror)parseroptionmsgr#@/usr/lib/python3.8/site-packages/pip/_internal/cli/cmdoptions.pyraise_option_error)s r%cCs,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)groupr Z option_groupr!r#r#r$make_option_group7s r*csPdkr |fdd}dddg}tt||rL|j}|tjddd 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. Ncs t|dSN)getattr)n check_optionsr#r$getnameOsz+check_install_build_global..getnameZ build_optionsglobal_optionsinstall_optionszeDisabling all use of wheels due to the use of --build-options / --global-options / --install-options.) stacklevel)anymapformat_controlZdisallow_binarieswarningswarn)r'r/r0namesZcontrolr#r.r$check_install_build_globalDs  r;FcCsbt|j|j|j|jg}ttdh}|j|ko6|j }|rH|rHt d|r^|r^|j s^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) r5python_versionplatformabiimplementationr setr7ignore_dependenciesr Z target_dir)r'Z check_targetZdist_restriction_setZ binary_onlyZsdist_dependencies_allowedr#r#r$check_dist_restriction[s&  rBz-hz--helphelpz Show help.)destactionrCz --isolated isolated_mode store_truezSRun pip in an isolated mode, ignoring environment variables and user configuration.rDrEdefaultrCz--require-virtualenvz--require-venvZ require_venvz-vz --verboseverbosecountzDGive more output. Option is additive, and can be used up to 3 times.z --no-colorno_colorzSuppress colored outputz-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))rDtypechoicesrIrCz--logz --log-filez --local-loglogpathz Path to a verbose appending log.)rDmetavarrCz --no-inputno_inputz--proxyproxystrz/src". The default for global installs is "/src".cCs t||jS)zGet a format_control object.)r,rD)valuesr!r#r#r$_get_format_controlsrycCs"t|j|}t||j|jdSr+)ryrxr handle_mutual_excludes no_binary only_binaryr!opt_strvaluer Zexistingr#r#r$_handle_no_binarys  rcCs"t|j|}t||j|jdSr+)ryrxr rzr|r{r}r#r#r$_handle_only_binarys  rc Cs$ttt}tdddtd|ddS)Nz --no-binaryr7callbackrYa^Do 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, 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.rDrErrRrIrC)r r@rrr7r#r#r$r{sr{c Cs$ttt}tdddtd|ddS)Nz --only-binaryr7rrYaGDo 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)r r@rrrr#r#r$r|sr|z --platformr=z[Only use wheels compatible with . Defaults to the platform of the running system.cCs|sdS|d}t|dkr"dSt|dkrV|d}t|dkrV|d|ddg}ztdd |D}Wntk rYd SX|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. )NN.)r#z'at most three version parts are allowedrNcss|]}t|VqdSr+)r\).0partr#r#r$ sz*_convert_python_version..)r#z$each version part must be an integer)rlentuple ValueError)rparts version_infor#r#r$_convert_python_versions    rcCs:t|\}}|dk r.d||}t|||d||j_dS)z3 Handle a provided --python-version value. Nz(invalid --python-version value: {!r}: {}r!r")rrr%rxr<)r!r~rr rZ error_msgr"r#r#r$_handle_python_version s rz--python-versionr<ra 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). )rDrVrErrRrIrCz--implementationr?zOnly 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--abir>zOnly use wheels compatible with Python abi , e.g. 'pypy_41'. If not specified, then the current interpreter abi tag is used. Generally you will need to specify --implementation, --platform, and --python-version when using this option.cCs4|t|t|t|tdSr+)r(r=r<r?r>)Zcmd_optsr#r#r$add_target_python_optionsIs   rcCst|j|j|j|jd}|S)N)r=Zpy_version_infor>r?)rr=r<r>r?)r'Z target_pythonr#r#r$make_target_pythonQsrcCstddddddS)Nz--prefer-binary prefer_binaryrGFz8Prefer older binary packages over newer source packages.rHrir#r#r#r$r]srz --cache-dir cache_dirzStore the cache data in .)rDrIrVrCc CsV|dk rJz t|Wn4tk rH}zt||t|dW5d}~XYnXd|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%rYrxr)r!optrr excr#r#r$_handle_no_cache_dirrs  $ rz--no-cache-dirzDisable the cache.)rDrErrCz --no-depsz--no-dependenciesrAz#Don't install package dependencies.z-bz--buildz --build-dirz--build-directory build_dira>Directory to unpack packages into and build in. Note that an initial build still takes place in a temporary directory. The location of temporary directories can be controlled by setting the TMPDIR environment variable (TEMP on Windows) appropriately. When passed, build directories are not cleaned in case of failures.z--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.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. rF)r%rx use_pep517)r!rrr r"r#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)rDrErrIrCz--install-optionr2rhr'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.)rDrErVrCz--global-optionr1zTExtra global options to be supplied to the setup.py call before the install command.z --no-cleanz!Don't clean up build directories.)rErIrCz--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.z-Zz--always-unzip always_unzipcCs|jjsi|j_z|dd\}}Wn"tk rF|d|YnX|tkrh|d|dtf|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 %s must be a hash name followed by a value, like --hash=sha256:abcde...z&Allowed hash algorithms for %s are %s.z, N) rxhashesrrrrr setdefaultrh)r!r~rr ZalgoZdigestr#r#r$_handle_merge_hash)s  rz--hashrstringzgVerify that the package's archive matches this hash before installing. Example: --hash=sha256:abcdef...)rDrErrRrCz--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).cCs|jr|js|jrtddS)Nz2Cannot combine '--path' with '--user' or '--local')rUuserZlocalr )r'r#r#r$check_list_path_option_srzGeneral Options)r&r'zPackage Index Options)N)F)t__doc__Z __future__rZloggingrr8Zdistutils.utilr functoolsrZoptparserrrrZpip._internal.exceptionsr Zpip._internal.locationsr r Z#pip._internal.models.format_controlr Zpip._internal.models.indexr Z"pip._internal.models.target_pythonrZpip._internal.utils.hashesrZpip._internal.utils.typingrZpip._internal.utils.uirtypingrrrrrrrZpip._internal.cli.parserrZ getLogger__name__Zloggerr%r*r;rBZhelp_rFZrequire_virtualenvrJrLrMrNlistkeysrrOrTrWrXr[r^rarbrjrkZ simple_urlrlrnrorprrrsrurvsrcryrrr{r|r=rrr<r?r>rrrrrZno_cacheZno_depsrrZno_build_isolationrrZ no_use_pep517r2r1Zno_cleanZprerrrhashrZ list_pathrZ general_groupZ index_groupr#r#r#r$sB               ,