o Ec*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)Z pip_pkg_dirr8K/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;r8r8r9normalize_version_infoRs    r?r2c Cs`zt|WdSty/}z|jtjkr|jtjkr$WYd}~dSWYd}~dSd}~ww)z os.path.makedirs without EEXIST.N)r1makedirsOSErrorerrnoZEEXISTZ ENOTEMPTY)r2er8r8r9r-esr-c CsJztjtjd}|dvrtjdWS|WStttfy$YdSw)Nr)z __main__.pyz-cz -m pippip) r1r2basenamesysargv executableAttributeError TypeError IndexError)progr8r8r9r+osr+Tr<g?)ZreraisestopwaitFdir ignore_errorscCstj||tddS)N)rPonerror)shutilr"rmtree_errorhandler)rOrPr8r8r9r"}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_IWRITErAchmod)rUr2rVZhas_attr_readonlyr8r8r9rSs rScCsFtjtj|}|ttjjr!d|ttd}|S)zTGives the display value for a given path, making it relative to cwd if possible..N)r1r2normcaser6 startswithgetcwdsepr>r2r8r8r9r#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)rOrbn extensionr8r8r9r$s r$messageoptionscCs2tjddD] }||vr|Sq t||S)NZPIP_EXISTS_ACTION)r1environgetsplitr%)rhriactionr8r8r9ask_path_existss  rocCstjdr td|dS)z&Raise an error if no input is allowed.Z PIP_NO_INPUTz5No input was expected ($PIP_NO_INPUT set); question: N)r1rkrl Exceptionrhr8r8r9_check_no_inputs rrcCsD t|t|}|}||vrtd|d|n|Sq)z@Ask the message interactively, with the given possible responsesrcz>Your response ({!r}) was not one of the expected responses: {}z, )rrinputstriplowerprintr7r3)rhriZresponser8r8r9r%s r%cCst|t|S)zAsk for input interactively.)rrrsrqr8r8r9 ask_inputsrwcCst|t|S)z!Ask for a password interactively.)rrgetpassrqr8r8r9 ask_passwords ryvalcCs.|}|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. )yZyesttrueZon1rc)rfZnofZfalseZoff0rzinvalid truth value )ru ValueError)rzr8r8r9 strtobools rbytescCsX|dkr d|ddS|dkrdt|dS|dkr%d|dSdt|S) Ni@Bz {:.1f} MBg@@ii'z{} kBz {:.1f} kBz{} bytes)r7int)rr8r8r9r'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|qSr8)tuplemapre.0rowr8r8r9 ztabulate..cSrr8)maxrr>)rcolr8r8r9rr fillvaluerjcs$g|]}dttj|qS) )r3rreljustrstriprZsizesr8r9rs$)r)rtabler8rr9tabulatesrcCsHtj|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)r1r2isdirisfiler3r`r8r8r9r(s r(filesizeccs ||}|s dS|Vq)z7Yield pieces of data from a file-like object until EOF.TN)read)rrchunkr8r8r9 read_chunkss rresolve_symlinkscCs6tj|}|rtj|}ntj|}tj|S)zN Convert a path to its canonical, case-normalized, absolute version. )r1r2 expanduserrealpathr6r\)r2rr8r8r9r)s   r)cCs@t|\}}|dr|dd|}|dd}||fS)z,Like os.path.splitext, but take off .tar tooz.tarN) posixpathr&ruendswith)r2baserbr8r8r9r&$s  r&oldnewcCstj|\}}|r|rtj|st|t||tj|\}}|r<|r>zt|WdSty;YdSwdSdS)z7Like os.renames(), but handles renaming across devices.N) r1r2rmrdr@rRZmove removedirsrA)rrheadtailr8r8r9r*-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!r]r)rFprefixr`r8r8r9is_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_locationrr8r8r9 dist_is_localLs rcCt|ttS)zF Return True if given Distribution is installed in user site. )rr]r)rrr8r8r9dist_in_usersiteWsrcCr)z[ Return True if given Distribution is installed in sysconfig.get_python_lib(). )rr]r)rrr8r8r9dist_in_site_packages^srcCs*tt|}|ttdjddS)zf Return True if given Distribution is installed in path matching distutils_scheme layout. rjZpythonr)r)rr]rZpurelibrm)rZ norm_pathr8r8r9dist_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)Zpip._internal.metadatarZ$pip._internal.metadata.pkg_resourcesrget_distributionrZ_dist)rrZ_Distrr8r8r9rps    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 Z project_namer)location)rZegg_linkr8r8r9rs  rmsgargscGstj|g|RdSN)loggerinfo)rrr8r8r9 write_outputsrc@s<eZdZUdZeed<ededdfddZeddZ dS) StreamWrapperN orig_streamr0cCs ||_|Sr)r)clsrr8r8r9 from_streamszStreamWrapper.from_streamcCs|jjSr)rencodingselfr8r8r9rszStreamWrapper.encoding) __name__ __module__ __qualname__rr__annotations__ classmethodrpropertyrr8r8r8r9rs 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)getattrrFsetattrrr)rZ orig_stdoutr8r8r9captured_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. stdoutrr8r8r8r9r,s r,cCr)z See captured_stdout(). stderrrr8r8r8r9captured_stderrsr sequentialnamedcOsDtt|tt|fi|}dd|D}||d<tdd|S)NcSsi|]\}}||qSr8r8)rkeyvaluer8r8r9 szenum..Zreverse_mappingEnumr8)dictzipranger>itemstype)rrZenumsreverser8r8r9enums rhostportcCs.|dur|Sd|vrd|d}|d|S)z. Build a netloc from a host-port pair N:[]r8)rrr8r8r9 build_netlocs  rhttpsnetlocschemecCs8|ddkrd|vrd|vrd|d}|d|S)z) Build a full URL from a netloc. r@rrz://)count)rrr8r8r9build_url_from_netlocs rcCs t|}tj|}|j|jfS)z2 Return the host-port pair from a netloc. )rurllibparseurlparsehostnamer)rurlparsedr8r8r9 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)NNrcNr)rsplitrmrrunquote)rauthZpwuserr8r8r9split_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****rjz:****z{user}{password}@{netloc})rpasswordr)rrrquoter7)rrrr8r8r9 redact_netloc s rrtransform_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) rrurlsplitrrr2queryfragment urlunsplitr)rrZpurlZ netloc_tupleZ url_piecesZsurlr8r8r9_transform_urls  rcCst|Sr)rrr8r8r9 _get_netloc3srcCs t|fSr)rrr8r8r9_redact_netloc7s rcCst|t\}\}}|||fS)z Parse a url into separate netloc, auth, and url with no auth. Returns: (url_without_auth, netloc, (username, password)) rr)rZurl_without_authrrr8r8r9split_auth_netloc_from_url;s r cCt|tdS)z7Return a copy of url with 'username:password@' removed.rrrr8r8r9r.Esr.cCr )z.Replace the password in a given url with ****.r)rrr r8r8r9redact_auth_from_urlLsr c@sPeZdZdededdfddZdefddZdefd d Zd edefd d Z dS) HiddenTextsecretredactedr0NcCs||_||_dSr)rr)rrrr8r8r9__init__Rs zHiddenText.__init__cCsdt|S)Nz)r7rerr8r8r9__repr__VszHiddenText.__repr__cCs|jSrrrr8r8r9__str__YszHiddenText.__str__othercCs t|t|kr dS|j|jkS)NF)rr)rrr8r8r9__eq__]s zHiddenText.__eq__) rrrrerrrrboolrr8r8r8r9r Qs r rcCs t|ddS)Nrr)r )rr8r8r9 hide_valuefs rcCst|}t||dS)Nr)r r )rrr8r8r9hide_urljs r 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-mrDrcz3To modify pip, please run the following command: {}r) r7rF version_inforr1r2rErGrHrr3)rZ pip_namesZshould_show_use_python_msgZ new_commandr8r8r9(protect_pip_from_modification_on_windowsosrcCstjduo tjS)zIs this console interactive?N)rFstdinisattyr8r8r8r9is_console_interactiverTr blocksizecCslt}d}t|d}t||dD] }|t|7}||qWd||fS1s-wY||fS)z5Return (hash, length) for path using hashlib.sha256()rrb)rN)hashlibZsha256openrr>update)r2r hZlengthrblockr8r8r9 hash_files    r'cCs$zddl}WdStyYdSw)z8 Return whether the wheel package is installed. rNFT)wheel ImportError)r(r8r8r9is_wheel_installeds   r*iterablecCst|}t||S)zb Return paired elements. For example: s -> (s0, s1), (s2, s3), (s4, s5), ... )iterr)r+r8r8r9pairwises r-predcCs 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)r.r+t1t2r8r8r9 partitions r2)F)ra)T)r)r)} contextlibrBrxr"ioZloggingr1rrRrWrF urllib.parserr itertoolsrrrtypesrtypingrrr r r r r rrrrrrZpip._vendor.pkg_resourcesrZpip._vendor.tenacityrrrrDrZpip._internal.exceptionsrZpip._internal.locationsrrrrZpip._internal.utils.compatrZpip._internal.utils.egg_linkr Zpip._internal.utils.virtualenvr!__all__Z getLoggerrrr/ BaseExceptionZExcInforr=rerr:r?r-r+rr"rSr#r$rorrr%rwryrfloatr'rr(DEFAULT_BUFFER_SIZErrr)r&r*rrrrrrrrrcontextmanagerrr,rrrrrrrrrrr r.r r rrrrr'r*r-r2r8r8r8r9s  <        $  "  *             $   "