3 igO @sddlZddlZddlZddlZddlZddlZddlZddlZddlZddl 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 l0m1Z1dd l2m3Z3dd l4m5Z5dddddddddddddg Z6ej7e8Z9e dZ:eee;e;efZee?eee?ee?ffZ@e?dddZAee=dfee=e=e=fd d!d"ZBe?dd#d$dZCe?dd%dZDe%d&e&d'e'd(d)de?eEdd+d,dZFedefe?eZNe?e=d?d@dAZOePe?dBdCdZQeeeeee?ee=fdDdEdFZRe?eEd#dGdZSejTfee=eeUdHdIdJZVde?eEe?dKdLdZWe?ee?e?fd#dMdZXe?e?ddNdOdZYe?eEd#dPdQZZe#eEdRdSdTZ[e#eEdRdUdVZ\e#eEdRdWdXZ]e?ee#dYdZd[Z^e#e?dRd\d]Z_eedd^d_d`Z`Gdadbdbe Zaejbe?eeadcdddeZceeaddfdZdeeaddgdhZeeeeedidjdkZfe?ee=e?dldmdnZgde?e?e?dpdqdrZhe?ee?ee=fdsdtduZie?e@dsdvdwZje?e?dsdxdyZke?ee?geedffee?e@fdzd{d|Zle?e@dsd}d~Zme?ee?dsddZne?ee?e?ee?e?ffdddZoe?e?dddZpe?e?dddZqGdddZre?erdddZse?erdddZteEddddZueEdddZvde?e=eee=fdddZweEdddZxeeeeeefdddZyee:geEfee:eee:ee:fdddZzdS)N)StringIO) filterfalsetee zip_longest) TracebackType) AnyBinaryIOCallableContextManagerIterableIteratorListOptionalTextIOTupleTypeTypeVarcast) Distribution)retrystop_after_delay wait_fixed) __version__) CommandError)get_major_minor_version site_packages user_site)WINDOWS)egg_link_path_from_location)running_under_virtualenvrmtree display_path backup_dirasksplitext format_sizeis_installable_dirnormalize_pathrenamesget_progcaptured_stdout ensure_dirremove_auth_from_urlT)returncCs4tjjtjjtdd}tjj|}djt|tS)Nz..zpip {} from {} (python {})) ospathjoindirname__file__abspathformatrr) pip_pkg_dirr77/tmp/pip-build-88gy_88q/pip/pip/_internal/utils/misc.pyget_pip_versionFs  r9.)py_version_infor.cCsDt|dkr"|dt|d7}nt|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)r)lenr)r:r7r7r8normalize_version_infoQs   r>)r0r.cCsPytj|Wn<tk rJ}z |jtjkr:|jtjkr:WYdd}~XnXdS)z os.path.makedirs without EEXIST.N)r/makedirsOSErrorerrnoEEXISTZ ENOTEMPTY)r0er7r7r8r+ds c CsNy.tjjtjd}|dkr(tjdS|SWntttfk rHYnXdS)Nr __main__.py-cz -m pippip)rDrE) r/r0basenamesysargv executableAttributeError TypeError IndexError)progr7r7r8r)ns Tr;g?)reraisestopwaitF)dir ignore_errorsr.cCstj||tddS)N)rSonerror)shutilr rmtree_errorhandler)rRrSr7r7r8r |s)funcr0exc_infor.c CsRytj|jtj@ }Wntk r,dSX|rLtj|tj||dSdS)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)r/statst_modeS_IWRITEr@chmod)rWr0rXZhas_attr_readonlyr7r7r8rVsrVcCsFtjjtjj|}|jtjtjjrBd|ttjd}|S)zTGives the display value for a given path, making it relative to cwd if possible..N)r/r0normcaser4 startswithgetcwdsepr=)r0r7r7r8r!s.bak)rRextr.cCs:d}|}x(tjj||r0|d7}|t|}q W||S)z\Figure out the name of a directory to back up the given dir to (adding .bak, .bak2, etc))r/r0existsstr)rRrcn extensionr7r7r8r"s )messageoptionsr.cCs2x&tjjddjD]}||kr|SqWt||S)NPIP_EXISTS_ACTION)r/environgetsplitr#)rirjactionr7r7r8ask_path_existssrq)rir.cCstjjdrtd|dS)z&Raise an error if no input is allowed. PIP_NO_INPUTz5No input was expected ($PIP_NO_INPUT set); question: N)r/rmrn Exception)rir7r7r8_check_no_inputs rtcCsJxDt|t|}|jj}||kr>tdj|dj|q|SqWdS)z@Ask the message interactively, with the given possible responsesz>Your response ({!r}) was not one of the expected responses: {}z, N)rtinputstriplowerprintr5r1)rirjresponser7r7r8r#s cCst|t|S)zAsk for input interactively.)rtru)rir7r7r8 ask_inputsrzcCst|tj|S)z!Ask for a password interactively.)rtgetpass)rir7r7r8 ask_passwordsr|)valr.cCs2|j}|dkrdS|dkr dStd|dS)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. yyesttrueon1rdrgnoffalseoff0rzinvalid truth value N)r~rrrrr)rgrrrrr)rw ValueError)r}r7r7r8 strtobools r)bytesr.cCs\|dkrdj|ddS|d kr4djt|dS|dkrJdj|dSdjt|SdS) Niz {:.1f} MBg@@ z{} kBz {:.1f} kBz{} bytesi@Bi')r5int)rr7r7r8r%s)rowsr.cs@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]) cSsg|]}ttt|qSr7)tuplemaprf).0rowr7r7r8 sztabulate..cSsg|]}ttt|qSr7)maxrr=)rcolr7r7r8rs fillvaluerlcs$g|]}djttj|jqS) )r1rrfljustrstrip)rr)sizesr7r8rs)r)rtabler7)rr8tabulatesrcCsHtjj|sdStjjtjj|dr*dStjjtjj|drDdSdS)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)r/r0isdirisfiler1)r0r7r7r8r&s )filesizer.ccs x|j|}|sP|VqWdS)z7Yield pieces of data from a file-like object until EOF.N)read)rrchunkr7r7r8 read_chunks s  r)r0resolve_symlinksr.cCs6tjj|}|rtjj|}n tjj|}tjj|S)zN Convert a path to its canonical, case-normalized, absolute version. )r/r0 expanduserrealpathr4r^)r0rr7r7r8r's   cCs@tj|\}}|jjdr8|dd|}|dd}||fS)z,Like os.path.splitext, but take off .tar tooz.tarNr) posixpathr$rwendswith)r0basercr7r7r8r$#s  )oldnewr.c Cs|tjj|\}}|r0|r0tjj| r0tj|tj||tjj|\}}|rx|rxytj|Wntk rvYnXdS)z7Like os.renames(), but handles renaming across devices.N) r/r0rorer?rUmove removedirsr@)rrheadtailr7r7r8r(,s  cCsts dS|jttjS)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)rr_r'rHprefix)r0r7r7r8is_local=s r)distr.cCs 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_location)rr7r7r8 dist_is_localKsrcCst|jttS)zF Return True if given Distribution is installed in user site. )rr_r'r)rr7r7r8dist_in_usersiteVsrcCst|jttS)z[ Return True if given Distribution is installed in sysconfig.get_python_lib(). )rr_r'r)rr7r7r8dist_in_site_packages]sr)req_namer.cCs<ddlm}ddlm}|j|}|dkr0dSt||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_environment)rN)Zpip._internal.metadatarZ$pip._internal.metadata.pkg_resourcesrget_distributionrZ_dist)rrZ_Distrr7r7r8res    rcCs t|j}|rt|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_linkr7r7r8rvs r)msgargsr.cGstj|f|dS)N)loggerinfo)rrr7r7r8 write_outputsrc@s6eZdZUdZeeeddddZeddZdS) StreamWrapperN) orig_streamr.cCs ||_|S)N)r)clsrr7r7r8 from_streamszStreamWrapper.from_streamcCs|jjS)N)rencoding)selfr7r7r8rszStreamWrapper.encoding) __name__ __module__ __qualname__rr classmethodrpropertyrr7r7r7r8rs r) stream_namer.c cs@tt|}tt|tj|ztt|VWdtt||XdS)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)getattrrHsetattrrr)r orig_stdoutr7r7r8captured_outputs  rcCstdS)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. stdout)rr7r7r7r8r*s cCstdS)z See captured_stdout(). stderr)rr7r7r7r8captured_stderrsr) sequentialnamedr.cOs@tt|tt|f|}dd|jD}||d<tdf|S)NcSsi|]\}}||qSr7r7)rkeyvaluer7r7r8 szenum..Zreverse_mappingEnum)dictzipranger=itemstype)rrenumsreverser7r7r8enumsr)hostportr.cCs.|dkr |Sd|kr d|d}|d|S)z. Build a netloc from a host-port pair N:[]r7)rrr7r7r8 build_netlocs  rhttps)netlocschemer.cCs8|jddkr*d|kr*d|kr*d|d}|d|S)z) Build a full URL from a netloc. r@rrz://)count)rrr7r7r8build_url_from_netlocs r)rr.cCs t|}tjj|}|j|jfS)z2 Return the host-port pair from a netloc. )rurllibparseurlparsehostnamer)rurlparsedr7r7r8 parse_netlocs rcCstd|kr|dfS|jdd\}}d}d|kr>|jdd\}}n |d}}tjj|}|dk rhtjj|}|||ffS)zp Parse out and remove the auth information from a netloc. Returns: (netloc, (username, password)). rNrdr)NN)rsplitrorrunquote)rauthpwuserr7r7r8split_auth_from_netlocs   rcCsNt|\}\}}|dkr|S|dkr.d}d}ntjj|}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" Nz****rlz:****z{user}{password}@{netloc})rpasswordr)rrrquoter5)rrrr7r7r8 redact_netlocs r)rtransform_netlocr.cCsJtjj|}||j}|j|d|j|j|jf}tjj|}|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) rrurlsplitrrr0queryfragment urlunsplitr)rrpurlZ netloc_tuple url_piecessurlr7r7r8_transform_urls   r cCst|S)N)r)rr7r7r8 _get_netloc(sr cCs t|fS)N)r)rr7r7r8_redact_netloc,sr )rr.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 )rZurl_without_authrrr7r7r8split_auth_netloc_from_url0srcCst|tdS)z7Return a copy of url with 'username:password@' removed.r)r r )rr7r7r8r,:scCst|tdS)z.Replace the password in a given url with ****.r)r r )rr7r7r8redact_auth_from_urlAsrc@sJeZdZeeddddZedddZeddd Zeed d d Z dS) HiddenTextN)secretredactedr.cCs||_||_dS)N)rr)rrrr7r7r8__init__GszHiddenText.__init__)r.cCsdjt|S)Nz)r5rf)rr7r7r8__repr__KszHiddenText.__repr__cCs|jS)N)r)rr7r7r8__str__NszHiddenText.__str__)otherr.cCs t|t|krdS|j|jkS)NF)rr)rrr7r7r8__eq__RszHiddenText.__eq__) rrrrfrrrrboolrr7r7r7r8rFsr)rr.cCs t|ddS)Nz****)r)r)rr7r7r8 hide_value[srcCst|}t||dS)N)r)rr)rrr7r7r8hide_url_sr) modifying_pipr.cCszddjtjddjtjddg}|oBtoBtjjtjd|k}|rvtjddgtjd d}t d jd j |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-mrFrdz3To modify pip, please run the following command: {}r) r5rH version_inforr/r0rGrIrJrr1)rZ pip_namesZshould_show_use_python_msgZ new_commandr7r7r8(protect_pip_from_modification_on_windowsdsrcCstjdk otjjS)zIs this console interactive?N)rHstdinisattyr7r7r7r8is_console_interactive~sr rd)r0 blocksizer.c CsVtj}d}t|d2}x*t||dD]}|t|7}|j|q&WWdQRX||fS)z5Return (hash, length) for path using hashlib.sha256()rrb)rN)hashlibsha256openrr=update)r0r"hlengthrblockr7r7r8 hash_files  r+c Cs&y ddl}Wntk r dSXdS)z8 Return whether the wheel package is installed. rNFT)wheel ImportError)r,r7r7r8is_wheel_installeds  r.)iterabler.cCst|}t||S)zb Return paired elements. For example: s -> (s0, s1), (s2, s3), (s4, s5), ... )iterr)r/r7r7r8pairwisesr1)predr/r.cCs 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)r2r/t1t2r7r7r8 partitions r6)F)rb)T)r)r7){ contextlibrAr{r$iologgingr/rrUrYrH urllib.parserr itertoolsrrrtypesrZtypingrrr r r r r rrrrrrZpip._vendor.pkg_resourcesrZpip._vendor.tenacityrrrrFrZpip._internal.exceptionsrZpip._internal.locationsrrrZpip._internal.utils.compatrZpip._internal.utils.egg_linkrZpip._internal.utils.virtualenvr__all__ getLoggerrrr- BaseExceptionZExcInforr<rfrr9r>r+r)rr rVr!r"rqrtr#rzr|rfloatr%rr&DEFAULT_BUFFER_SIZErrr'r$r(rrrrrrrrcontextmanagerrr*rrrrrrrr r r rr,rrrrrr r+r.r1r6r7r7r7r8s  <        "    (        "