o ai*Q @s~ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddlm Z ddlmZmZmZddlmZddlmZmZmZmZmZmZmZmZmZmZmZm Z m!Z!ddl"m#Z#ddl$m%Z%m&Z&m'Z'ddl(m)Z)dd l*m+Z+dd l,m-Z-m.Z.m/Z/dd l,m0Z0dd l1m2Z2dd l3m4Z4ddl5m6Z6gdZ7e8e9Z:e dZ;eee<ee>e>fZ?ee@eee@ee@ffZAde@fddZBdee>dfdee>e>e>ffddZCde@ddfddZDde@fddZEe%de&de'dd dd"e@d#eFddfd$d%ZGd&edefde@d'e=ddfd(d)ZHde@de@fd*d+ZIdd"e@d-e@de@fd.d/ZJd0e@d1ee@de@fd2d3ZKd0e@ddfd4d5ZLd0e@d1ee@de@fd6d7ZMd0e@de@fd8d9ZNd0e@de@fd:d;ZOdfd=d>ZPd?eQde@fd@dAZRdBeeedeee@ee>ffdCdDZSde@deFfdEdFZTejUfdGedHe>deeVfdIdJZWdde@dKeFde@fdLdMZXde@dee@e@ffdNdOZYdPe@dQe@ddfdRdSZZde@deFfdTdUZ[dVe#deFfdWdXZ\dVe#deFfdYdZZ]dVe#deFfd[d\Z^d]d^Z_d_e@dee#fd`daZ`dVe#de@fdbdcZaddedeeddfdfdgZbGdhdidie Zcejddje@deecfdkdlZedeecfdmdnZfdeecfdodpZgdqedredeefdsdtZhdue@dvee>de@fdwdxZiddze@d{e@de@fd|d}Zjdze@dee@ee>ffd~dZkdze@deAfddZldze@de@fddZmde@dee@geedffdee@eAffddZndze@deAfddZodze@dee@fddZpde@dee@e@ee@e@fffddZqde@de@fddZrde@de@fddZsGdddZtde@detfddZude@detfddZvdeFddfddZwdeFfddZxdde@de>deee>ffddZydeFfddZzdeedeeeeffddZ{dee;geFfdee;deee;ee;ffddZ|dS)N)StringIO) filterfalsetee zip_longest) TracebackType) AnyBinaryIOCallableContextManagerIterableIteratorListOptionalTextIOTupleTypeTypeVarcast Distribution)retrystop_after_delay wait_fixed) __version__) CommandError)get_major_minor_version site_packages user_site) get_scheme)WINDOWS)egg_link_path_from_location)running_under_virtualenv) rmtree display_path backup_dirasksplitext format_sizeis_installable_dirnormalize_pathrenamesget_progcaptured_stdout ensure_dirremove_auth_from_urlTreturncCs4tjtjtdd}tj|}dt|tS)Nz..zpip {} from {} (python {})) ospathjoindirname__file__abspathformatrr) pip_pkg_dirr9/builddir/build/BUILDROOT/alt-python310-pip-21.3.1-5.el8.x86_64/opt/alt/python310/lib/python3.10/site-packages/pip/_internal/utils/misc.pyget_pip_versionGs r;py_version_info.cCsDt|dkr|dt|d7}n t|dkr|dd}td|S)ax Convert a tuple of ints representing a Python version to one of length three. :param py_version_info: a tuple of ints representing a Python version, or None to specify no version. The tuple can have any length. :return: a tuple of length three if `py_version_info` is non-None. Otherwise, return `py_version_info` unchanged (i.e. None). )rN VersionInfo)lenr)r<r9r9r:normalize_version_infoRs    r@r2c Cs`zt|WdSty/}z|jtjkr|jtjkr$WYd}~dSWYd}~dSd}~ww)z os.path.makedirs without EEXIST.N)r1makedirsOSErrorerrnoEEXIST ENOTEMPTY)r2er9r9r:r-esr-c CsJztjtjd}|dvrtjdWS|WStttfy$YdSw)Nr)z __main__.pyz-cz -m pippip) r1r2basenamesysargv executableAttributeError TypeError IndexError)progr9r9r:r+osr+Tr=g?)reraisestopwaitFdir ignore_errorscCstj||tddS)N)rTonerror)shutilr"rmtree_errorhandler)rSrTr9r9r:r"}r"funcexc_infocCsNz t|jtj@ }Wn tyYdSw|r&t|tj||dS)zOn Windows, the files in .svn are read-only, so when rmtree() tries to remove them, an exception is thrown. We catch that here, remove the read-only attribute, and hopefully continue without problems.N)r1statst_modeS_IWRITErBchmod)rYr2rZhas_attr_readonlyr9r9r:rWs rWcCsFtjtj|}|ttjjr!d|ttd}|S)zTGives the display value for a given path, making it relative to cwd if possible..N)r1r2normcaser6 startswithgetcwdsepr?r2r9r9r:r#sr#.bakextcCsDd}|}tj||r|d7}|t|}tj||s ||S)z\Figure out the name of a directory to back up the given dir to (adding .bak, .bak2, etc))r1r2existsstr)rSrgn extensionr9r9r:r$s r$messageoptionscCs2tjddD] }||vr|Sq t||S)NPIP_EXISTS_ACTION)r1environgetsplitr%)rmrnactionr9r9r:ask_path_existss  rucCstjdr td|dS)z&Raise an error if no input is allowed. PIP_NO_INPUTz5No input was expected ($PIP_NO_INPUT set); question: N)r1rqrr Exceptionrmr9r9r:_check_no_inputs rycCsD t|t|}|}||vrtd|d|n|Sq)z@Ask the message interactively, with the given possible responsesrhz>Your response ({!r}) was not one of the expected responses: {}z, )ryinputstriplowerprintr7r3)rmrnresponser9r9r:r%s r%cCst|t|S)zAsk for input interactively.)ryrzrxr9r9r: ask_inputsrcCst|t|S)z!Ask for a password interactively.)rygetpassrxr9r9r: ask_passwords rvalcCs.|}|dvr dS|dvrdStd|)zConvert a string representation of truth to true (1) or false (0). True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values are 'n', 'no', 'f', 'false', 'off', and '0'. Raises ValueError if 'val' is anything else. )yyesttrueon1rh)rknoffalseoff0rzinvalid truth value )r| ValueError)rr9r9r: strtobools rbytescCsX|dkr d|ddS|dkrdt|dS|dkr%d|dSdt|S) Ni@Bz {:.1f} MBg@@ii'z{} kBz {:.1f} kBz{} bytes)r7int)rr9r9r:r'sr'rowscs@dd|D}ddt|ddiDfdd|D}|fS)zReturn a list of formatted rows and a list of column sizes. For example:: >>> tabulate([['foobar', 2000], [0xdeadbeef]]) (['foobar 2000', '3735928559'], [10, 4]) cSg|] }ttt|qSr9)tuplemaprj.0rowr9r9r: ztabulate..cSrr9)maxrr?)rcolr9r9r:rr fillvaluerpcs$g|]}dttj|qS) )r3rrjljustrstriprsizesr9r:rs$)r)rtabler9rr:tabulatesrcCsHtj|sdStjtj|drdStjtj|dr"dSdS)atIs path is a directory containing pyproject.toml or setup.py? If pyproject.toml exists, this is a PEP 517 project. Otherwise we look for a legacy setuptools layout by identifying setup.py. We don't check for the setup.cfg because using it without setup.py is only available for PEP 517 projects, which are already covered by the pyproject.toml check. Fzpyproject.tomlTzsetup.py)r1r2isdirisfiler3rer9r9r:r(s r(filesizeccs ||}|s dS|Vq)z7Yield pieces of data from a file-like object until EOF.TN)read)rrchunkr9r9r: read_chunkss rresolve_symlinkscCs6tj|}|rtj|}ntj|}tj|S)zN Convert a path to its canonical, case-normalized, absolute version. )r1r2 expanduserrealpathr6ra)r2rr9r9r:r)s   r)cCs@t|\}}|dr|dd|}|dd}||fS)z,Like os.path.splitext, but take off .tar tooz.tarN) posixpathr&r|endswith)r2basergr9r9r:r&$s  r&oldnewcCstj|\}}|r|rtj|st|t||tj|\}}|r<|r>zt|WdSty;YdSwdSdS)z7Like os.renames(), but handles renaming across devices.N) r1r2rsrirArVmove removedirsrB)rrheadtailr9r9r:r*-s   r*cCstsdS|ttjS)z Return True if path is within sys.prefix, if we're running in a virtualenv. If we're not in a virtualenv, all paths are considered "local." Caution: this function assumes the head of path has been normalized with normalize_path. T)r!rbr)rIprefixrer9r9r:is_local>s rdistcCs tt|S)z Return True if given Distribution object is installed locally (i.e. within current virtualenv). Always True if we're not in a virtualenv. )r dist_locationrr9r9r: dist_is_localLs rcCt|ttS)zF Return True if given Distribution is installed in user site. )rrbr)rrr9r9r:dist_in_usersiteWsrcCr)z[ Return True if given Distribution is installed in sysconfig.get_python_lib(). )rrbr)rrr9r9r:dist_in_site_packages^srcCs*tt|}|ttdjddS)zf Return True if given Distribution is installed in path matching distutils_scheme layout. rppythonr)r)rrbrpurelibrs)r norm_pathr9r9r:dist_in_install_pathfs rreq_namecCs<ddlm}ddlm}||}|durdSt||jS)a%Given a requirement name, return the installed Distribution object. This searches from *all* distributions available in the environment, to match the behavior of ``pkg_resources.get_distribution()``. Left for compatibility until direct pkg_resources uses are refactored out. r)get_default_environmentrN)pip._internal.metadatar$pip._internal.metadata.pkg_resourcesrget_distributionr_dist)rr_Distrr9r9r:rps    rcCs t|j}|r t|St|jS)aO Get the site-packages location of this distribution. Generally this is dist.location, except in the case of develop-installed packages, where dist.location is the source code location, and we want to know where the egg-link file is. The returned location is normalized (in particular, with symlinks removed). )r project_namer)location)regg_linkr9r9r:rs  rmsgargscGstj|g|RdSN)loggerinfo)rrr9r9r: write_outputsrc@s<eZdZUdZeed<ededdfddZeddZ dS) StreamWrapperN orig_streamr0cCs ||_|Sr)r)clsrr9r9r: from_streamszStreamWrapper.from_streamcCs|jjSr)rencodingselfr9r9r:rszStreamWrapper.encoding) __name__ __module__ __qualname__rr__annotations__ classmethodrpropertyrr9r9r9r:rs r stream_namec csLtt|}tt|t|ztt|VWtt||dStt||w)zReturn a context manager used by captured_stdout/stdin/stderr that temporarily replaces the sys stream *stream_name* with a StringIO. Taken from Lib/support/__init__.py in the CPython repo. N)getattrrIsetattrrr)r orig_stdoutr9r9r:captured_outputs  rcCtdS)zCapture the output of sys.stdout: with captured_stdout() as stdout: print('hello') self.assertEqual(stdout.getvalue(), 'hello ') Taken from Lib/support/__init__.py in the CPython repo. stdoutrr9r9r9r:r,s r,cCr)z See captured_stdout(). stderrrr9r9r9r:captured_stderrsr sequentialnamedcOsDtt|tt|fi|}dd|D}||d<tdd|S)NcSsi|]\}}||qSr9r9)rkeyvaluer9r9r: szenum..reverse_mappingEnumr9)dictzipranger?itemstype)rrenumsreverser9r9r:enums rhostportcCs.|dur|Sd|vrd|d}|d|S)z. Build a netloc from a host-port pair N:[]r9)rrr9r9r: build_netlocs  rhttpsnetlocschemecCs8|ddkrd|vrd|vrd|d}|d|S)z) Build a full URL from a netloc. r@rrz://)count)rrr9r9r:build_url_from_netlocs rcCs t|}tj|}|j|jfS)z2 Return the host-port pair from a netloc. )rurllibparseurlparsehostnamer)rurlparsedr9r9r: parse_netlocs  rcCstd|vr|dfS|dd\}}d}d|vr|dd\}}n|d}}tj|}|dur4tj|}|||ffS)zp Parse out and remove the auth information from a netloc. Returns: (netloc, (username, password)). r)NNrhNr)rsplitrsr r unquote)rauthpwuserr9r9r:split_auth_from_netlocs    rcCsNt|\}\}}|dur|S|durd}d}ntj|}d}dj|||dS)z Replace the sensitive data in a netloc with "****", if it exists. For example: - "user:pass@example.com" returns "user:****@example.com" - "accesstoken@example.com" returns "****@example.com" N****rpz:****z{user}{password}@{netloc})rpasswordr)rr r quoter7)rrrr9r9r: redact_netloc s rr transform_netloccCsJtj|}||j}|j|d|j|j|jf}tj|}|t d|fS)aRTransform and replace netloc in a url. transform_netloc is a function taking the netloc and returning a tuple. The first element of this tuple is the new netloc. The entire tuple is returned. Returns a tuple containing the transformed url as item 0 and the original tuple returned by transform_netloc as item 1. r NetlocTuple) r r urlsplitrrr2queryfragment urlunsplitr)r rpurl netloc_tuple url_piecessurlr9r9r:_transform_urls  r$cCst|Sr)rrr9r9r: _get_netloc3sr&cCs t|fSr)rr%r9r9r:_redact_netloc7s r'cCst|t\}\}}|||fS)z Parse a url into separate netloc, auth, and url with no auth. Returns: (url_without_auth, netloc, (username, password)) r$r&)r url_without_authrrr9r9r:split_auth_netloc_from_url;s r*cCt|tdS)z7Return a copy of url with 'username:password@' removed.rr(r r9r9r:r.Esr.cCr+)z.Replace the password in a given url with ****.r)r$r'r,r9r9r:redact_auth_from_urlLsr-c@sPeZdZdededdfddZdefddZdefd d Zd edefd d Z dS) HiddenTextsecretredactedr0NcCs||_||_dSr)r/r0)rr/r0r9r9r:__init__Rs zHiddenText.__init__cCsdt|S)Nz)r7rjrr9r9r:__repr__VszHiddenText.__repr__cCs|jSrr0rr9r9r:__str__YszHiddenText.__str__othercCs t|t|kr dS|j|jkS)NF)rr/)rr5r9r9r:__eq__]s zHiddenText.__eq__) rrrrjr1r2r4rboolr6r9r9r9r:r.Qs r.rcCs t|ddS)Nrr3)r.)rr9r9r: hide_valuefs r8cCst|}t||dS)Nr3)r-r.)r r0r9r9r:hide_urljs r9 modifying_pipcCszddtjddjtjddg}|o!to!tjtjd|v}|r;tjddgtjd d}t d d |dS) zProtection of pip.exe from modification on Windows On Windows, any operation modifying pip should be run as: python -m pip ... zpip.exez pip{}.exerz pip{}.{}.exeNrz-mrGrhz3To modify pip, please run the following command: {}r) r7rI version_inforr1r2rHrJrKrr3)r: pip_namesshould_show_use_python_msg new_commandr9r9r:(protect_pip_from_modification_on_windowsosr?cCstjduo tjS)zIs this console interactive?N)rIstdinisattyr9r9r9r:is_console_interactiverXrB blocksizecCslt}d}t|d}t||dD] }|t|7}||qWd||fS1s-wY||fS)z5Return (hash, length) for path using hashlib.sha256()rrb)rN)hashlibsha256openrr?update)r2rDhlengthrblockr9r9r: hash_files    rMcCs$zddl}WdStyYdSw)z8 Return whether the wheel package is installed. rNFT)wheel ImportError)rNr9r9r:is_wheel_installeds   rPiterablecCst|}t||S)zb Return paired elements. For example: s -> (s0, s1), (s2, s3), (s4, s5), ... )iterr)rQr9r9r:pairwises rSpredcCs t|\}}t||t||fS)z Use a predicate to partition entries into false entries and true entries, like partition(is_odd, range(10)) --> 0 2 4 6 8 and 1 3 5 7 9 )rrfilter)rTrQt1t2r9r9r: partitions rX)F)rf)T)r)rC)} contextlibrCrrFiologgingr1rrVr[rI urllib.parser r itertoolsrrrtypesrtypingrrr r r r r rrrrrrpip._vendor.pkg_resourcesrpip._vendor.tenacityrrrrGrpip._internal.exceptionsrpip._internal.locationsrrrrpip._internal.utils.compatrpip._internal.utils.egg_linkr pip._internal.utils.virtualenvr!__all__ getLoggerrrr/ BaseExceptionExcInforr>rjrr;r@r-r+r7r"rWr#r$ruryr%rrrfloatr'rr(DEFAULT_BUFFER_SIZErrr)r&r*rrrrrrrrrcontextmanagerrr,rrrrrrrr$r&r'r*r.r-r.r8r9r?rBrMrPrSrXr9r9r9r:s  <        $  "  *             $   "