U n aSf@sddlmZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl mZddlmZddlmZddlmZmZddlmZmZmZddlmZdd lmZdd l m!Z!dd l"m#Z#dd l$m%Z%m&Z&m'Z'dd l(m)Z)m*Z*m+Z+m,Z,ddl-m.Z.m/Z/ddl0m1Z1m2Z2erZ>m?Z?ddl@mAZAe>eBeBeBfZCddddddddddddd d!gZDeEeFZGd"d#ZHd$d%ZId&dZJd'dZKed(d)d*dd,dZLd-d.ZMd/d0ZNd1dZOdd3dZPd4d5ZQd6d7ZRd8dZSd9d:ZTd;d<ZUd=dZVd>d?ZWd@dZXejYfdAdBZZddDdZ[dEdZ\dFdZ]dGdHZ^dIdJZ_dKdLZ`dMdNZadOdPZbdCe+dCd+d+dfdQdRZcdSdTZddUdVZedWdXZfGdYdZdZegZhGd[d\d\e4Ziejjd]d^Zkd_dZld`daZmGdbdcdcegZndddd ZodedfZpdgdhZqdidjZrddldmZsdndoZtdpdqZudrdsZvdtduZwdvdwZxdxdyZydzd{Zzd|d!Z{d}d~Z|GdddegZ}ddZ~ddZddZddZdddZddZddZdS))absolute_importNdeque) pkg_resources)retry)PY2 text_type)inputmap zip_longest)parse)unquote) __version__) CommandError)get_major_minor_version site_packages user_site)WINDOWS expanduser stdlib_pkgsstr_to_display)MYPY_CHECK_RUNNINGcast)running_under_virtualenvvirtualenv_no_global)BytesIO)StringIO) AnyAnyStr ContainerIterableIteratorListOptionalTextTupleUnion) Distributionrmtree 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_dirr>YC:\Users\vtejo\AppData\Local\Temp\pip-unpacked-wheel-6mt8ur68\pip\_internal\utils\misc.pyget_pip_versionKs r@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)lenr)py_version_infor>r>r?normalize_version_infoWs   rEc CsPzt|Wn<tk rJ}z|jtjkr:|jtjkr:W5d}~XYnXdS)z os.path.makedirs without EEXIST.N)r6makedirsOSErrorerrnoEEXIST ENOTEMPTY)r7er>r>r?r3ks c CsRz2tjtjd}|dkr*dtjWS|WSWnttt fk rLYnXdS)Nr)z __main__.pyz-cz {} -m pippip) r6r7basenamesysargvr< executableAttributeError TypeError IndexError)progr>r>r?r1vs i i)stop_max_delay wait_fixedFcCstj||tddS)N) ignore_errorsonerror)shutilr(rmtree_errorhandler)dirrWr>r>r?r(sc 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)r6statst_modeS_IWRITEIOErrorrGchmod)funcr7exc_infohas_attr_readonlyr>r>r?rZsrZcCsd|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}) isinstancerdecoderNgetfilesystemencodingUnicodeDecodeErrorrrr<ascii)r7r)r>r>r?path_to_displays  rjcCsttjtj|}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)r6r7normcaser;rN version_inforfrgencodegetdefaultencoding startswithgetcwdseprCr7r>r>r?r)s.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))r6r7existsstr)r[extn extensionr>r>r?r*s cCs2tjddD]}||kr|Sqt||S)NPIP_EXISTS_ACTION)r6environgetsplitr+)messageoptionsactionr>r>r?ask_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)r6rr Exceptionr<rr>r>r?_check_no_inputs  rcCsFt|t|}|}||krYour response ({!r}) was not one of the expected responses: {}z, N)rr striplowerprintr<r8)rrresponser>r>r?r+s cCst|t|S)zAsk for input interactively.)rr rr>r>r? ask_inputsrcCst|t|S)z!Ask for a password interactively.)rgetpassrr>r>r? ask_passwordsrcCs\|dkrd|ddS|dkr4dt|dS|dkrJd|dSdt|SdS) Ni@Bz {:.1f} MBg@@ii'z{} kBz {:.1f} kBz{} bytes)r<int)bytesr>r>r?r- scs@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|qSr>)tupler ry.0rowr>r>r? sztabulate..cSsg|]}ttt|qSr>)maxr rC)rcolr>r>r?r s fillvaluer~cs$g|]}dttj|qS) )r8r ryljustrstriprsizesr>r?r!s)r )rowstabler>rr?tabulates rcCsPtj|sdStj|d}tj|r.dStj|d}tj|rLdSdS)zBIs path is a directory containing setup.py or pyproject.toml? Fzsetup.pyTzpyproject.toml)r6r7isdirr8isfile)r7setup_pypyproject_tomlr>r>r?r.%s   ccs||}|sq|VqdS)z7Yield pieces of data from a file-like object until EOF.N)read)filesizechunkr>r>r? read_chunks4s rTcCs2t|}|rtj|}n tj|}tj|S)zN Convert a path to its canonical, case-normalized, absolute version. )rr6r7realpathr;rn)r7resolve_symlinksr>r>r?r/=s  cCs@t|\}}|dr8|dd|}|dd}||fS)z,Like os.path.splitext, but take off .tar tooz.tarN) posixpathr,rendswith)r7baserzr>r>r?r,Ks  cCsztj|\}}|r.|r.tj|s.t|t||tj|\}}|rv|rvzt|Wntk rtYnXdS)z7Like os.renames(), but handles renaming across devices.N) r6r7rrxrFrYmove removedirsrG)oldnewheadtailr>r>r?r0Us  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)rrrr/rNprefixrur>r>r?is_localgs 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_locationdistr>r>r? dist_is_localvs rcCst|ttS)zF Return True if given Distribution is installed in user site. )rrrr/rrr>r>r?dist_in_usersitesrcCst|ttS)z[ Return True if given Distribution is installed in sysconfig.get_python_lib(). )rrrr/rrr>r>r?dist_in_site_packagessrcCs6tjD]*}tj||jd}tj|rdSqdS)zC Return True if given Distribution is an editable install. .egg-linkTF)rNr7r6r8 project_namer)r path_itemegg_linkr>r>r?dist_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. cSsdSNTr>dr>r>r? local_testsz/get_installed_distributions..local_testcSsdSrr>rr>r>r? editable_testsz2get_installed_distributions..editable_testcSs t| SNrrr>r>r?rscSst|Srrrr>r>r?editables_only_testsz8get_installed_distributions..editables_only_testcSsdSrr>rr>r>r?rscSsdSrr>rr>r>r? user_testsz.get_installed_distributions..user_testcs:g|]2}|r|jkr|r|r|r|qSr>)key)rrrrrskiprr>r?rs z/get_installed_distributions..)r WorkingSet working_setrr) local_onlyrinclude_editableseditables_only user_onlypathsrr>rr?get_installed_distributionss    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) rappendrrrr6r7r8rr)rsitessiteegglinkr>r>r? egg_link_paths       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). )rr/location)rrr>r>r?rs rcGstj|f|dSr)loggerinfo)msgargsr>r>r? write_outputsrc@s(eZdZdZddZddZddZdS) FakeFilezQWrap a list of lines in an object with readline() to make ConfigParser happy.cCsdd|D|_dS)Ncss|] }|VqdSrr>)rlr>r>r? sz$FakeFile.__init__.._gen)selflinesr>r>r?__init__szFakeFile.__init__cCsPz4zt|jWWStk r0|jYWSXWntk rJYdSXdS)Nr~)nextr NameError StopIterationrr>r>r?readline"szFakeFile.readlinecCs|jSrrrr>r>r?__iter__+szFakeFile.__iter__N)__name__ __module__ __qualname____doc__rrrr>r>r>r?rs rc@s$eZdZeddZeddZdS) StreamWrappercCs ||_|Sr) orig_stream)clsrr>r>r? from_stream1szStreamWrapper.from_streamcCs|jjSr)rencodingrr>r>r?r7szStreamWrapper.encodingN)rrr classmethodrpropertyrr>r>r>r?r/s 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)getattrrNsetattrrr) stream_name orig_stdoutr>r>r?captured_output<s  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. stdoutrr>r>r>r?r2Ks cCstdS)z See captured_stdout(). stderrrr>r>r>r?captured_stderrWsrc@s eZdZdZddZddZdS)cached_propertyzA property that is only computed once per instance and then replaces itself with an ordinary attribute. Deleting the attribute resets the property. Source: https://github.com/bottlepy/bottle/blob/0.11.5/bottle.py#L175 cCst|d|_||_dS)Nr)rrra)rrar>r>r?rfs zcached_property.__init__cCs(|dkr |S||}|j|jj<|Sr)ra__dict__r)robjrvaluer>r>r?__get__jszcached_property.__get__N)rrrrrr r>r>r>r?r^srcCs4tj|}|dkrt}||}|r0|jSdS)zCGet the installed version of dist_name avoiding pkg_resources cacheN)r Requirementr rfindversion) dist_namerreqrr>r>r?r4rs   cCst|dddS)zConsume an iterable at C speed.r)maxlenNr)iteratorr>r>r?consumesrcOs@tt|tt|f|}dd|D}||d<tdd|S)NcSsi|]\}}||qSr>r>)rrr r>r>r? szenum..reverse_mappingEnumr>)dictziprangerCitemstype) sequentialnamedenumsreverser>r>r?enumsrcCs*|dkr |Sd|krd|}d||S)z. Build a netloc from a host-port pair N:[{}]z{}:{})r<)hostportr>r>r? build_netlocs  r$httpscCs4|ddkr(d|kr(d|kr(d|}d||S)z) Build a full URL from a netloc. r rk@[r!z{}://{})countr<)netlocschemer>r>r?build_url_from_netlocs r+cCst|}t|}|j|jfS)z2 Return the host-port pair from a netloc. )r+ urllib_parseurlparsehostnamer#)r)urlparsedr>r>r? parse_netlocs r1cCsXd|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)). r&)NNrwr Ncss"|]}|dkrdnt|VqdSr)urllib_unquote)rxr>r>r?rsz)split_auth_from_netloc..)rsplitrr)r)auth user_passr>r>r?split_auth_from_netlocsr7cCsLt|\}\}}|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****r~z:****z{user}{password}@{netloc})userpasswordr))r7r,quoter<)r)r9r:r>r>r? redact_netlocs  r<cCs@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)r,urlsplitr)r*r7queryfragment urlunsplit)r/transform_netlocpurl netloc_tuple url_piecessurlr>r>r?_transform_urls   rFcCst|Sr)r7r)r>r>r? _get_netlocsrHcCs t|fSr)r<rGr>r>r?_redact_netlocsrIcCst|t\}\}}|||fS)z Parse a url into separate netloc, auth, and url with no auth. Returns: (url_without_auth, netloc, (username, password)) rFrH)r/url_without_authr)r5r>r>r?split_auth_netloc_from_urlsrLcCst|tdS)z7Return a copy of url with 'username:password@' removed.rrJr/r>r>r?r5 scCst|tdS)z.Replace the password in a given url with ****.r)rFrIrMr>r>r?redact_auth_from_urlsrNc@s4eZdZddZddZddZddZd d Zd S) HiddenTextcCs||_||_dSr)secretredacted)rrPrQr>r>r?rszHiddenText.__init__cCsdt|S)Nz)r<ryrr>r>r?__repr__%szHiddenText.__repr__cCs|jSrrQrr>r>r?__str__)szHiddenText.__str__cCs t|t|krdS|j|jkS)NF)rrProtherr>r>r?__eq__.szHiddenText.__eq__cCs ||k Srr>rUr>r>r?__ne__9szHiddenText.__ne__N)rrrrrRrTrWrXr>r>r>r?rOs   rOcCs t|ddS)Nr8rS)rO)r r>r>r? hide_value>srYcCst|}t||dS)NrS)rNrO)r/rQr>r>r?hide_urlCsrZcCszddtjddjtjddg}|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{}.{}.exeNrkz-mrLrwz3To modify pip, please run the following command: {}r) r<rNrorr6r7rMrOrPrr8) modifying_pip pip_namesshould_show_use_python_msg new_commandr>r>r?(protect_pip_from_modification_on_windowsIs* r_cCstjdk otjS)z!Is this console interactive? N)rNstdinisattyr>r>r>r?is_console_interactivegsrbc CsRt}d}t|d.}t||dD]}|t|7}||q$W5QRX||fS)z:Return (hash, length) for path using hashlib.sha256() rrb)r)hashlibsha256openrrCupdate)r7 blocksizehlengthfblockr>r>r? hash_filens  rncCs(z ddl}Wntk r"YdSXdS)z8 Return whether the wheel package is installed. rNFT)wheel ImportError)ror>r>r?is_wheel_installed|s  rqcCst|}t||S)zb Return paired elements. For example: s -> (s0, s1), (s2, s3), (s4, s5), ... )iterr )iterabler>r>r?pairwisesrt)F)rv)T)N)r%)rc) __future__r contextlibrHrreiologgingr6rrYr\rN collectionsr pip._vendorrpip._vendor.retryingrZpip._vendor.sixrrpip._vendor.six.movesr r r Zpip._vendor.six.moves.urllibr r,"pip._vendor.six.moves.urllib.parser r2rLrpip._internal.exceptionsrpip._internal.locationsrrrpip._internal.utils.compatrrrrpip._internal.utils.typingrrpip._internal.utils.virtualenvrrrrtypingrrrr r!r"r#r$r%r&Zpip._vendor.pkg_resourcesr'rrB__all__ getLoggerrrr@rEr3r1r(rZrjr)r*rrr+rrr-rr.DEFAULT_BUFFER_SIZErr/r,r0rrrrrrrrrobjectrrcontextmanagerrr2rrr4rrr$r+r1r7r<rFrHrIrLr5rNrOrYrZr_rbrnrqrtr>r>r>r?s         0      "         D$       #