U v_n@s,ddlmZddlZddlZddlZddlZddlZddlZddlZddl 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/m0Z0m1Z1m2Z2m3Z3ddl4m5Z5m6Z6ddl7m8Z8m9Z9er`ddlm:Z;n ddlm;Z;e5rddlZ>m?Z?m@Z@mAZAmBZBmCZCmDZDmEZEmFZFmGZGmHZHddlImJZJeFeKeKeKfZLeGdZMdddddddddd d!d"d#d$gZNeOePZQd%d&ZRd'd(ZSd)d"ZTd*d ZUed+d,d-dd/dZVd0d1ZWd2d3ZXd4dZYdd6dZZd7d8Z[d9d:Z\d;dZ]dd?Z_d@dZ`dAdBZadCdZbejcfdDdEZdddGdZedHdZfdIdZgdJdKZhdLdMZidNdOZjdPdQZkdRdSZldTdUZmdFe2dFd.d.dfdVdWZndXdYZodZd[Zpd\d]Zqd^d_Zrd`daZsGdbdcdcetZuGdddedee;ZvejwdfdgZxdhd!ZydidjZzddkd#Z{dldmZ|dndoZ}dpdqZ~ddsdtZdudvZdwdxZdydzZd{d|Zd}d~ZddZddZdd$ZddZGdddetZddZddZddZddZdddZddZddZddZdS))absolute_importNdeque)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_urlcCs4tjtjtdd}tj|}dt|tS)Nz..zpip {} from {} (python {})) ospathjoindirname__file__abspathformatrr) pip_pkg_dirrF/builddir/build/BUILDROOT/alt-python38-pip-20.2.4-1.el7.x86_64/opt/alt/python38/lib/python3.8/site-packages/pip/_internal/utils/misc.pyget_pip_versionOs rHcCsDt|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)lenr)py_version_inforFrFrGnormalize_version_info[s   rMc CsPzt|Wn<tk rJ}z|jtjkr:|jtjkr:W5d}~XYnXdS)z os.path.makedirs without EEXIST.N)r>makedirsOSErrorerrnoEEXIST ENOTEMPTY)r?erFrFrGr;os c CsRz2tjtjd}|dkr*dtjWS|WSWnttt fk rLYnXdS)Nr)z __main__.pyz-cz {} -m pippip) r>r?basenamesysargvrD executableAttributeError TypeError IndexError)progrFrFrGr9zs i i)stop_max_delay wait_fixedFcCstj||tddS)N) ignore_errorsonerror)shutilr0rmtree_errorhandler)dirr_rFrFrGr0sc CsXzt|jtj@ }Wnttfk r2YdSX|rRt|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_IWRITEIOErrorrOchmod)funcr?exc_infohas_attr_readonlyrFrFrGrbsrbcCsd|dkr dSt|tr|Sz|td}Wn0tk r^trRtd|}nt |}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 decoderVgetfilesystemencodingUnicodeDecodeErrorr rrDascii)r?r1rFrFrGpath_to_displays  rrcCsttjtj|}tjddkrB|td}|t d}| t tjj rpd|t t d}|S)zTGives the display value for a given path, making it relative to cwd if possible.rreplace.N)r>r?normcaserCrV version_infornroencodegetdefaultencoding startswithgetcwdseprKr?rFrFrGr1s.bakcCs6d}|}tj||r.|d7}|t|}q||S)z\Figure out the name of a directory to back up the given dir to (adding .bak, .bak2, etc))r>r?existsstr)rcextn extensionrFrFrGr2s cCs2tjddD]}||kr|Sqt||S)NPIP_EXISTS_ACTION)r>environgetsplitr3)messageoptionsactionrFrFrGask_path_existss rcCstjdrtd|dS)z&Raise an error if no input is allowed. PIP_NO_INPUTz7No input was expected ($PIP_NO_INPUT set); question: {}N)r>rr ExceptionrDrrFrFrG_check_no_inputs  rcCsFt|t|}|}||krYour response ({!r}) was not one of the expected responses: {}z, N)rr striplowerprintrDr@)rrresponserFrFrGr3s cCst|t|S)zAsk for input interactively.)rr rrFrFrG ask_inputsrcCst|t|S)z!Ask for a password interactively.)rgetpassrrFrFrG ask_passwordsrcCs\|dkrd|ddS|dkr4dt|dS|dkrJd|dSdt|SdS) Ni@Bz {:.1f} MBg@@ii'z{} kBz {:.1f} kBz{} bytes)rDint)bytesrFrFrGr5scs@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|qSrF)tuplerr.0rowrFrFrG #sztabulate..cSsg|]}ttt|qSrF)maxrrK)rcolrFrFrGr$s fillvaluercs$g|]}dttj|qS) )r@rrljustrstriprsizesrFrGr%s)r)rowstablerFrrGtabulates rcCsPtj|sdStj|d}tj|r.dStj|d}tj|rLdSdS)zBIs path is a directory containing setup.py or pyproject.toml? Fzsetup.pyTzpyproject.toml)r>r?isdirr@isfile)r?setup_pypyproject_tomlrFrFrGr6)s   ccs||}|sq|VqdS)z7Yield pieces of data from a file-like object until EOF.N)read)filesizechunkrFrFrG read_chunks8s rTcCs2t|}|rtj|}n tj|}tj|S)zN Convert a path to its canonical, case-normalized, absolute version. )rr>r?realpathrCrv)r?resolve_symlinksrFrFrGr7As  cCs@t|\}}|dr8|dd|}|dd}||fS)z,Like os.path.splitext, but take off .tar tooz.tarN) posixpathr4rendswith)r?baserrFrFrGr4Os  cCsztj|\}}|r.|r.tj|s.t|t||tj|\}}|rv|rvzt|Wntk rtYnXdS)z7Like os.renames(), but handles renaming across devices.N) r>r?rrrNramove removedirsrO)oldnewheadtailrFrFrGr8Ys  cCsts dS|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)rrzr7rVprefixr}rFrFrGis_localks rcCs 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_locationdistrFrFrG dist_is_localzs rcCst|ttS)zF Return True if given Distribution is installed in user site. )rrzr7rrrFrFrGdist_in_usersitesrcCst|ttS)z[ Return True if given Distribution is installed in sysconfig.get_python_lib(). )rrzr7rrrFrFrGdist_in_site_packagessrcCs,tt|}|ttddddS)zf Return True if given Distribution is installed in path matching distutils_scheme layout. rpurelibpythonr)r7rrzrr)r norm_pathrFrFrGdist_in_install_paths rcCs6tjD]*}tj||jd}tj|rdSqdS)zC Return True if given Distribution is an editable install. .egg-linkTF)rVr?r>r@ project_namer)r path_itemegg_linkrFrFrGdist_is_editables   rcs|rt|}ntj}|r tndd|r6ddndd|rLddndd|r^tnd 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. cSsdSNTrFdrFrFrG local_testsz/get_installed_distributions..local_testcSsdSrrFrrFrFrG editable_testsz2get_installed_distributions..editable_testcSs t| SNrrrFrFrGrscSst|SrrrrFrFrGeditables_only_testsz8get_installed_distributions..editables_only_testcSsdSrrFrrFrFrGrscSsdSrrFrrFrFrG user_testsz.get_installed_distributions..user_testcs:g|]2}|r|jkr|r|r|r|qSrF)key)rrrrrskiprrFrGrs z/get_installed_distributions..)r WorkingSet working_setrr) local_onlyrinclude_editableseditables_only user_onlypathsrrFrrGget_installed_distributionss    rcCs4t|}tddddddd}dd|D}||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()``. FrFTN)rrrrrrcSsi|]}t|j|qSrF)rr)rprFrFrG sz(_search_distribution..)rrr)req_namepackagespkg_dictrFrFrG_search_distributions rcCs>t|}|s6ztj|Wntjk r4YdSXt|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)rrrFrFrGget_distributions  rcCsxg}tr*|ttsBtrB|tntr8|t|t|D],}tj||jd}tj |rF|SqFdS)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. rN) rappendrrrr>r?r@rr)rsitessiteegglinkrFrFrG egg_link_path$s       rcCst|}|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). )rr7location)rrrFrFrGrHs rcGstj|f|dSr)loggerinfo)msgargsrFrFrG write_outputXsrc@s(eZdZdZddZddZddZdS) FakeFilezQWrap a list of lines in an object with readline() to make ConfigParser happy.cCst||_dSr)iter_gen)selflinesrFrFrG__init__`szFakeFile.__init__cCs(z t|jWStk r"YdSXdS)Nr)nextr StopIterationrrFrFrGreadlinecs zFakeFile.readlinecCs|jSr)rrrFrFrG__iter__iszFakeFile.__iter__N)__name__ __module__ __qualname____doc__rrrrFrFrFrGr]src@s$eZdZeddZeddZdS) StreamWrappercCs ||_|Sr) orig_stream)clsr rFrFrG from_streamoszStreamWrapper.from_streamcCs|jjSr)r encodingrrFrFrGr uszStreamWrapper.encodingN)rrr classmethodr propertyr rFrFrFrGrms rc cs@tt|}tt|t|ztt|VW5tt||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)getattrrVsetattrrr ) stream_name orig_stdoutrFrFrGcaptured_outputzs  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. stdoutrrFrFrFrGr:s cCstdS)z See captured_stdout(). stderrrrFrFrFrGcaptured_stderrsrcCs4tj|}|dkrt}||}|r0|jSdS)zCGet the installed version of dist_name avoiding pkg_resources cacheN)r Requirementrrfindversion) dist_namerreqrrFrFrGr<s   cCst|dddS)zConsume an iterable at C speed.r)maxlenNr)iteratorrFrFrGconsumesrcOs@tt|tt|f|}dd|D}||d<tdd|S)NcSsi|]\}}||qSrFrF)rrvaluerFrFrGrszenum..reverse_mappingEnumrF)dictziprangerKitemstype) sequentialnamedenumsreverserFrFrGenumsr,cCs*|dkr |Sd|krd|}d||S)z. Build a netloc from a host-port pair N:[{}]z{}:{})rD)hostportrFrFrG build_netlocs  r1httpscCs4|ddkr(d|kr(d|kr(d|}d||S)z) Build a full URL from a netloc. r-rs@[r.z{}://{})countrD)netlocschemerFrFrGbuild_url_from_netlocs r8cCst|}t|}|j|jfS)z2 Return the host-port pair from a netloc. )r8 urllib_parseurlparsehostnamer0)r6urlparsedrFrFrG parse_netlocs r>cCsXd|kr|dfS|dd\}}d|kr6|dd}n|df}tdd|D}||fS)zp Parse out and remove the auth information from a netloc. Returns: (netloc, (username, password)). r3)NNrr-Ncss"|]}|dkrdnt|VqdSr)urllib_unquote)rxrFrFrG sz)split_auth_from_netloc..)rsplitrr)r6auth user_passrFrFrGsplit_auth_from_netlocsrEcCsLt|\}\}}|dkr|S|dkr.d}d}nt|}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****rz:****z{user}{password}@{netloc})userpasswordr6)rEr9quoterD)r6rGrHrFrFrG redact_netlocs  rJcCs@t|}||j}|j|d|j|j|jf}t|}||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)r9urlsplitr6r7r?queryfragment urlunsplit)r<transform_netlocpurl netloc_tuple url_piecessurlrFrFrG_transform_urls   rTcCst|Sr)rEr6rFrFrG _get_netloc$srVcCs t|fSr)rJrUrFrFrG_redact_netloc(srWcCst|t\}\}}|||fS)z Parse a url into separate netloc, auth, and url with no auth. Returns: (url_without_auth, netloc, (username, password)) rTrV)r<url_without_authr6rCrFrFrGsplit_auth_netloc_from_url,srZcCst|tdS)z7Return a copy of url with 'username:password@' removed.rrXr<rFrFrGr=7scCst|tdS)z.Replace the password in a given url with ****.r)rTrWr[rFrFrGredact_auth_from_url?sr\c@s4eZdZddZddZddZddZd d Zd S) HiddenTextcCs||_||_dSr)secretredacted)rr^r_rFrFrGrFszHiddenText.__init__cCsdt|S)Nz)rDrrrFrFrG__repr__OszHiddenText.__repr__cCs|jSrr_rrFrFrG__str__SszHiddenText.__str__cCs t|t|krdS|j|jkS)NF)r'r^rotherrFrFrG__eq__XszHiddenText.__eq__cCs ||k SrrFrcrFrFrG__ne__cszHiddenText.__ne__N)rrrrr`rbrerfrFrFrFrGr]Es   r]cCs t|ddS)NrFra)r])r rFrFrG hide_valuehsrgcCst|}t||dS)Nra)r\r])r<r_rFrFrGhide_urlmsrhcCszddtjddjtjddg}|oBtoBtjtjd|k}|rvtjddgtjd 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{}.{}.exeNrsz-mrTrz3To modify pip, please run the following command: {}r) rDrVrwrr>r?rUrWrXrr@) modifying_pip pip_namesshould_show_use_python_msg new_commandrFrFrG(protect_pip_from_modification_on_windowsss* rmcCstjdk otjS)z!Is this console interactive? N)rVstdinisattyrFrFrFrGis_console_interactivesrpc CsRt}d}t|d.}t||dD]}|t|7}||q$W5QRX||fS)z:Return (hash, length) for path using hashlib.sha256() rrb)r)hashlibsha256openrrKupdate)r? blocksizehlengthfblockrFrFrG hash_files  r|cCs(z ddl}Wntk r"YdSXdS)z8 Return whether the wheel package is installed. rNFT)wheel ImportError)r}rFrFrGis_wheel_installeds  rcCst|}t||S)zb Return paired elements. For example: s -> (s0, s1), (s2, s3), (s4, s5), ... )rr)iterablerFrFrGpairwisesrcCs 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 )predrt1t2rFrFrG partitions r)F)r~)T)N)r2)rq) __future__r contextlibrPrrsiologgingr>rrardrV collectionsr itertoolsr pip._vendorrZpip._vendor.packaging.utilsrpip._vendor.retryingrZpip._vendor.sixr r pip._vendor.six.movesr r r rrZpip._vendor.six.moves.urllibrr9"pip._vendor.six.moves.urllib.parserr?rTrpip._internal.exceptionsrpip._internal.locationsrrrrpip._internal.utils.compatrrrrpip._internal.utils.typingrrpip._internal.utils.virtualenvrrr r!typingr"r#r$r%r&r'r(r)r*r+r,r-Zpip._vendor.pkg_resourcesr.rrJr/__all__ getLoggerrrrHrMr;r9r0rbrrr1r2rrr3rrr5rr6DEFAULT_BUFFER_SIZErr7r4r8rrrrrrrrrrrrobjectrrcontextmanagerrr:rr<rr,r1r8r>rErJrTrVrWrZr=r\r]rgrhrmrpr|rrrrFrFrFrGs           8      "          D$       #