Ren@sddlmZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl mZddlmZddlmZddlmZddlmZddlmZmZdd lmZmZmZmZmZdd l m!Z"dd l#m$Z%dd l&m'Z'dd l(m)Z)ddl*m+Z+m,Z,m-Z-m.Z.ddl/m0Z0m1Z1m2Z2m3Z3ddl4m5Z5m6Z6ddl7m8Z8m9Z9erddlm:Z;nddlm;Z;e5rddl<m=Z=m>Z>m?Z?m@Z@mAZAmBZBmCZCmDZDmEZEmFZFmGZGmHZHddlImJZJeFeKeKeKfZLeGdZMdddddddddd d!d"d#d$gZNejOePZQd%d&ZRd'd(ZSd)d"ZTd*d ZUed+d,d-d.d/d0dZVd1d2ZWd3d4ZXd5dZYd6d7dZZd8d9Z[d:d;Z\d<dZ]d=d>Z^d?d@Z_dAdZ`dBdCZadDdZbejcdEdFZddGdHdZedIdZfdJdZgdKdLZhdMdNZidOdPZjdQdRZkdSdTZldUdVZmdGe2dGd/d/ddWdXZndYdZZod[d\Zpd]d^Zqd_d`ZrdadbZsGdcddddetZuGdedfdfe;ZvejwdgdhZxdid!ZydjdkZzddld#Z{dmdnZ|dodpZ}dqdrZ~dsdtduZdvdwZdxdyZdzd{Zd|d}Zd~dZddZddZdd$ZddZGdddetZddZddZddZddZdddZddZddZddZdS))absolute_importN)deque)tee) pkg_resources)canonicalize_name)retry)PY2 text_type)filter filterfalseinputmap zip_longest)parse)unquote) __version__) CommandError)distutils_schemeget_major_minor_version site_packages user_site)WINDOWS expanduser stdlib_pkgsstr_to_display)MYPY_CHECK_RUNNINGcast)running_under_virtualenvvirtualenv_no_global)BytesIO)StringIO) AnyAnyStrCallable ContainerIterableIteratorListOptionalTextTupleTypeVarUnion) DistributionTrmtree display_path backup_dirasksplitext format_sizeis_installable_dirnormalize_pathrenamesget_progcaptured_stdout ensure_dirget_installed_versionremove_auth_from_urlcCsLtjjtjjtdd}tjj|}djt|tS)Nz..zpip {} from {} (python {})) ospathjoindirname__file__abspathformatrr) pip_pkg_dirrE/builddir/build/BUILDROOT/alt-python35-pip-20.2.4-5.el8.x86_64/opt/alt/python35/lib/python3.5/site-packages/pip/_internal/utils/misc.pyget_pip_versionOs$rGcCs\t|dkr-|dt|d7}n"t|dkrO|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)py_version_inforErErFnormalize_version_info[s rLcCsdytj|WnLtk r_}z,|jtjkrM|jtjkrMWYdd}~XnXdS)z os.path.makedirs without EEXIST.N)r=makedirsOSErrorerrnoEEXIST ENOTEMPTY)r>erErErFr:os $c Cs_y=tjjtjd}|dkr8djtjS|SWnttt fk rZYnXdS)Nr __main__.py-cz {} -m pippip)rSrT) r=r>basenamesysargvrC executableAttributeError TypeError IndexError)progrErErFr8zs stop_max_delayi wait_fixediFcCstj|d|dtdS)N ignore_errorsonerror)shutilr/rmtree_errorhandler)dirr`rErErFr/sc Cskytj|jtj@ }Wnttfk r<dSYnX|rdtj|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_IWRITEIOErrorrNchmod)funcr>exc_infohas_attr_readonlyrErErFrcs  rcc Cs|dkrdSt|tr#|Sy|jtjd}Wn<tk r}trmtdj|}n t |}YnX|S)z Convert a bytes (or text) path to text (unicode in Python 2) for display and logging purposes. This function should never error out. Also, this function is mainly needed for Python 2 since in Python 3 str paths are already text. Nstrictzb{!r}) isinstancer decoderWgetfilesystemencodingUnicodeDecodeErrorrrrCascii)r>r0rErErFpath_to_displays  rscCstjjtjj|}tjddkra|jtjd}|jtj d}|j tj tjj rd|t tj d}|S)zTGives the display value for a given path, making it relative to cwd if possible.rreplace.N)r=r>normcaserBrW version_infororpencodegetdefaultencoding startswithgetcwdseprJ)r>rErErFr0s z.bakcCsKd}|}x4tjj||rB|d7}|t|}qW||S)z\Figure out the name of a directory to back up the given dir to (adding .bak, .bak2, etc))r=r>existsstr)rdextn extensionrErErFr1s  cCsCx3tjjddjD]}||kr|SqWt||S)NPIP_EXISTS_ACTION)r=environgetsplitr2)messageoptionsactionrErErFask_path_existss" rcCs+tjjdr'tdj|dS)z&Raise an error if no input is allowed. PIP_NO_INPUTz7No input was expected ($PIP_NO_INPUT set); question: {}N)r=rr ExceptionrC)rrErErF_check_no_inputsrcCsex^t|t|}|jj}||krYtdj|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)rr striplowerprintrCr?)rrresponserErErFr2s   cCst|t|S)zAsk for input interactively.)rr )rrErErF ask_inputs rcCst|tj|S)z!Ask for a password interactively.)rgetpass)rrErErF ask_passwords rcCsx|dkr!dj|ddS|d krDdjt|dS|dkradj|dSdjt|SdS) Niz {:.1f} MBg@@ z{} kBz {:.1f} kBz{} bytesi@Bi')rCint)bytesrErErFr4s   csUdd|D}ddt|ddDfdd|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]) cSs%g|]}ttt|qSrE)tupler r).0rowrErErF #s ztabulate..cSs%g|]}ttt|qSrE)maxr rJ)rcolrErErFr$s fillvaluercs4g|]*}djttj|jqS) )r?r rljustrstrip)rr)sizesrErFr%s )r)rowstablerE)rrFtabulates rcCsptjj|sdStjj|d}tjj|rAdStjj|d}tjj|rldSdS)zBIs path is a directory containing setup.py or pyproject.toml? Fzsetup.pyTzpyproject.toml)r=r>isdirr?isfile)r>setup_pypyproject_tomlrErErFr5)sccs&x|j|}|sP|VqWdS)z7Yield pieces of data from a file-like object until EOF.N)read)filesizechunkrErErF read_chunks8s rTcCsIt|}|r'tjj|}ntjj|}tjj|S)zN Convert a path to its canonical, case-normalized, absolute version. )rr=r>realpathrBrw)r>resolve_symlinksrErErFr6As  cCsXtj|\}}|jjdrN|dd|}|dd}||fS)z,Like os.path.splitext, but take off .tar tooz.tarNr) posixpathr3rendswith)r>baserrErErFr3Os c Cstjj|\}}|rD|rDtjj| rDtj|tj||tjj|\}}|r|rytj|Wntk rYnXdS)z7Like os.renames(), but handles renaming across devices.N) r=r>rrrMrbmove removedirsrN)oldnewheadtailrErErFr7Ys   cCs#ts 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{r6rWprefix)r>rErErFis_localks rcCstt|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)distrErErF dist_is_localzs rcCst|jttS)zF Return True if given Distribution is installed in user site. )rr{r6r)rrErErFdist_in_usersitesrcCst|jttS)z[ Return True if given Distribution is installed in sysconfig.get_python_lib(). )rr{r6r)rrErErFdist_in_site_packagessrcCs<tt|}|jttddjddS)zf Return True if given Distribution is installed in path matching distutils_scheme layout. rpurelibpythonr)r6rr{rr)r norm_pathrErErFdist_in_install_paths rcCsJxCtjD]8}tjj||jd}tjj|r dSq WdS)zC Return True if given Distribution is an editable install. z .egg-linkTF)rWr>r=r? project_namer)r path_itemegg_linkrErErFdist_is_editables rcs|rtj|}n tj}|r0tn dd|rQddn dd|rrddn dd|rtn d d fd d |DS) a^ Return a list of installed Distribution objects. If ``local_only`` is True (default), only return installations local to the current virtualenv, if in a virtualenv. ``skip`` argument is an iterable of lower-case project names to ignore; defaults to stdlib_pkgs If ``include_editables`` is False, don't report editables. If ``editables_only`` is True , only report editables. If ``user_only`` is True , only report installations in the user site directory. If ``paths`` is set, only report the distributions present at the specified list of locations. cSsdS)NTrE)drErErF local_testsz/get_installed_distributions..local_testcSsdS)NTrE)rrErErF editable_testsz2get_installed_distributions..editable_testcSs t| S)N)r)rrErErFrscSs t|S)N)r)rrErErFeditables_only_testsz8get_installed_distributions..editables_only_testcSsdS)NTrE)rrErErFrscSsdS)NTrE)rrErErF user_testsz.get_installed_distributions..user_testcsUg|]K}|r|jkr|r|r|r|qSrE)key)rr)rrrskiprrErFrs    z/get_installed_distributions..)r WorkingSet working_setrr) local_onlyrinclude_editableseditables_only user_onlypathsrrE)rrrrrrFget_installed_distributionss        rc CsYt|}tdddfdddddddd }d d |D}|j|S) zFind a distribution matching the ``req_name`` in the environment. This searches from *all* distributions available in the environment, to match the behavior of ``pkg_resources.get_distribution()``. rFrrTrrrNcSs"i|]}|t|jqSrE)rr)rprErErF s z(_search_distribution..)rrr)req_namepackagespkg_dictrErErF_search_distributions  rc CsLt|}|sBytjj|Wntjk rAdSYnXt|S)zGiven 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()``. N)rrrrequireDistributionNotFound)rrrErErFget_distributions  rcCsg}tr<|jtt r\tr\|jtn trO|jt|jtx@|D]8}tjj||jd}tjj |rc|SqcWdS)a Return the path for the .egg-link file if it exists, otherwise, None. There's 3 scenarios: 1) not in a virtualenv try to find in site.USER_SITE, then site_packages 2) in a no-global virtualenv try to find in site_packages 3) in a yes-global virtualenv try to find in site_packages, then site.USER_SITE (don't look in global location) For #1 and #3, there could be odd cases, where there's an egg-link in 2 locations. This method will just return the first one found. z .egg-linkN) rappendrrrr=r>r?rr)rsitessiteegglinkrErErF egg_link_path$s     rcCs)t|}|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). )rr6location)rrrErErFrHs  rcGstj||dS)N)loggerinfo)msgargsrErErF write_outputXsrc@s:eZdZdZddZddZddZdS) FakeFilezQWrap a list of lines in an object with readline() to make ConfigParser happy.cCst||_dS)N)iter_gen)selflinesrErErF__init__`szFakeFile.__init__c Cs.yt|jSWntk r)dSYnXdS)Nr)nextr StopIteration)rrErErFreadlinecs zFakeFile.readlinecCs|jS)N)r)rrErErF__iter__iszFakeFile.__iter__N)__name__ __module__ __qualname____doc__rrrrErErErFr]s   rc@s4eZdZeddZeddZdS) StreamWrappercCs||_|S)N) orig_stream)clsrrErErF from_streamos zStreamWrapper.from_streamcCs |jjS)N)rencoding)rrErErFruszStreamWrapper.encodingN)rrr classmethodrpropertyrrErErErFrms rc csRtt|}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)getattrrWsetattrrr) stream_name orig_stdoutrErErFcaptured_outputzs r cCs tdS)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)r rErErErFr9s cCs tdS)z See captured_stdout(). stderr)r rErErErFcaptured_stderrsr cCsJtjj|}|dkr*tj}|j|}|rF|jSdS)zCGet the installed version of dist_name avoiding pkg_resources cacheN)r Requirementrrfindversion) dist_namerreqrrErErFr;s   cCst|dddS)zConsume an iterable at C speed.maxlenrN)r)iteratorrErErFconsumesrcOsWtt|tt||}dd|jD}||d.reverse_mappingEnum)dictziprangerJitemstype) sequentialnamedenumsreverserErErFenums$ r!cCs;|dkr|Sd|kr+dj|}dj||S)z. Build a netloc from a host-port pair N:z[{}]z{}:{})rC)hostportrErErF build_netlocs   r%httpscCsL|jddkr<d|kr<d|kr<dj|}dj||S)z) Build a full URL from a netloc. r"rt@[z[{}]z{}://{})countrC)netlocschemerErErFbuild_url_from_netlocs-r,cCs+t|}tj|}|j|jfS)z2 Return the host-port pair from a netloc. )r, urllib_parseurlparsehostnamer$)r*urlparsedrErErF parse_netlocs r2cCs~d|kr|dfS|jdd\}}d|krO|jdd}n |df}tdd|D}||fS)zp Parse out and remove the auth information from a netloc. Returns: (netloc, (username, password)). r'Nr~r"css-|]#}|dkrdn t|VqdS)N)urllib_unquote)rxrErErF sz)split_auth_from_netloc..)NN)rsplitrr)r*auth user_passrErErFsplit_auth_from_netlocs    r9cCstt|\}\}}|dkr(|S|dkrCd}d}ntj|}d}djd|d|d|S) 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****rz:****z{user}{password}@{netloc}userpasswordr*)r9r-quoterC)r*r:r;rErErF redact_netlocs    r=cCs\tj|}||j}|j|d|j|j|jf}tj|}||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)r-urlsplitr*r+r>queryfragment urlunsplit)r0transform_netlocpurl netloc_tuple url_piecessurlrErErF_transform_urls %rGcCs t|S)N)r9)r*rErErF _get_netloc$srHcCs t|fS)N)r=)r*rErErF_redact_netloc(srIcCs(t|t\}\}}|||fS)z Parse a url into separate netloc, auth, and url with no auth. Returns: (url_without_auth, netloc, (username, password)) )rGrH)r0url_without_authr*r7rErErFsplit_auth_netloc_from_url,srKcCst|tdS)z7Return a copy of url with 'username:password@' removed.r)rGrH)r0rErErFr<7scCst|tdS)z.Replace the password in a given url with ****.r)rGrI)r0rErErFredact_auth_from_url?srLc@sLeZdZddZddZddZddZd d Zd S) HiddenTextcCs||_||_dS)N)secretredacted)rrNrOrErErFrFs zHiddenText.__init__cCsdjt|S)Nz)rCr)rrErErF__repr__OszHiddenText.__repr__cCs|jS)N)rO)rrErErF__str__SszHiddenText.__str__cCs,t|t|krdS|j|jkS)NF)rrN)rotherrErErF__eq__XszHiddenText.__eq__cCs ||k S)NrE)rrRrErErF__ne__cszHiddenText.__ne__N)rrrrrPrQrSrTrErErErFrMEs    rMcCst|ddS)NrOz****)rM)rrErErF hide_valuehsrUcCst|}t|d|S)NrO)rLrM)r0rOrErErFhide_urlms rVcCsddjtjddjtjddg}|o]to]tjjtjd|k}|rtjddgtjd 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{}.{}.exeNrtz-mrUr~z3To modify pip, please run the following command: {}r) rCrWrxrr=r>rVrXrYrr?) modifying_pip pip_namesshould_show_use_python_msg new_commandrErErF(protect_pip_from_modification_on_windowsssr[cCstjdk otjjS)z!Is this console interactive? N)rWstdinisattyrErErErFis_console_interactivesr^r~c Csotj}d}t|dA}x7t|d|D]#}|t|7}|j|q7WWdQRX||fS)z:Return (hash, length) for path using hashlib.sha256() rrbrN)hashlibsha256openrrJupdate)r> blocksizehlengthfblockrErErF hash_files rjc Cs-yddl}Wntk r(dSYnXdS)z8 Return whether the wheel package is installed. rNFT)wheel ImportError)rkrErErFis_wheel_installeds   rmcCst|}t||S)zb Return paired elements. For example: s -> (s0, s1), (s2, s3), (s4, s5), ... )rr)iterablerErErFpairwises rocCs.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 )rr r )predrnt1t2rErErF partitions rsi) __future__r contextlibrOrraiologgingr=rrbrerW collectionsr itertoolsr pip._vendorrZpip._vendor.packaging.utilsrpip._vendor.retryingrZpip._vendor.sixrr pip._vendor.six.movesr r r r rZpip._vendor.six.moves.urllibrr-"pip._vendor.six.moves.urllib.parserr3rUrpip._internal.exceptionsrpip._internal.locationsrrrrpip._internal.utils.compatrrrrpip._internal.utils.typingrrpip._internal.utils.virtualenvrrrr typingr!r"r#r$r%r&r'r(r)r*r+r,Zpip._vendor.pkg_resourcesr-rrIr.__all__ getLoggerrrrGrLr:r8r/rcrsr0r1rrr2rrr4rr5DEFAULT_BUFFER_SIZErr6r3r7rrrrrrrrrrrrobjectrrcontextmanagerr r9r r;rr!r%r,r2r9r=rGrHrIrKr<rLrMrUrVr[r^rjrmrorsrErErErFs           (""R       "            >   $              #