"JdW "dZddlZddlZddlZddlZddlZddlmZm Z m Z m Z m Z m Z mZmZmZmZmZddlmZddlmZmZddlmZmZmZmZmZmZmZm Z ddl!m"Z"m#Z#m$Z$ddl%m&Z&erdd lm'Z'd gZ(ej)e*Z+eee,ee,fZ-d e,d e.fd Z/ d de,de,de,dee,d e,f dZ0de,de,d ee,fdZ1Gdde2Z3Gdde2Z4GddZ5GddZ6e6Z7GddZ8dS)!z)Handles all VCS (version control) supportN) TYPE_CHECKINGAnyDictIterableIteratorListMappingOptionalTupleTypeUnion)SpinnerInterface) BadCommandInstallationError) HiddenTextask_path_exists backup_dir display_pathhide_url hide_valueis_installable_dirrmtree) CommandArgscall_subprocess make_command)get_url_scheme)LiteralvcsnamereturncNt|}|dS|gdtjzvS)z3 Return true if the name looks like a URL. NF)httphttpsfileftp)rr all_schemes)rschemes S/opt/alt/python311/lib/python3.11/site-packages/pip/_internal/vcs/versioncontrol.pyis_urlr)4s4D ! !F ~u 555G GGrepo_urlrev project_namesubdircZ|dd}|d|d|}|r|d|z }|S)z Return the URL for a VCS requirement. Args: repo_url: the remote VCS url, with any needed VCS prefix (e.g. "git+"). project_name: the (unescaped) project name. -_@z#egg=z&subdirectory=)replace)r+r,r-r.egg_project_namereqs r(make_vcs_requirement_urlr6>sV$++C55  4 4 4 4"2 4 4C ) (((( Jr*location repo_rootcN|}t|sS|}tj|}||krtd|dSt|Stj||rdStj||S)z Find the the Python project's root by searching up the filesystem from `location`. Return the path to project root relative to `repo_root`. Return None if the project root is `repo_root`, or cannot be found. zOCould not find a Python project for directory %s (tried all parent directories)N)rospathdirnameloggerwarningsamefilerelpath)r7r8 orig_location last_locations r((find_path_to_project_root_from_repo_rootrCPsM **  7??8,, } $ $ NN&    4!**  w 8,,t 7??8Y / //r*ceZdZdS)RemoteNotFoundErrorN)__name__ __module__ __qualname__r*r(rErEmsDr*rEc$eZdZdeffd ZxZS)RemoteNotValidErrorurlcXt|||_dSN)super__init__rL)selfrL __class__s r(rPzRemoteNotValidError.__init__rs& r*)rFrGrHstrrP __classcell__rRs@r(rKrKqsDCr*rKc eZdZdZ ddeddeedeeddfdZdefd Z e deefd Z defd Z defd Z deddfd ZdS) RevOptionsz Encapsulates a VCS-specific revision to install, along with any VCS install options. Instances of this class should be treated as if immutable. Nvc_classVersionControlr, extra_argsr cF|g}||_||_||_d|_dS)z Args: vc_class: a VersionControl subclass. rev: the name of the revision to install. extra_args: a list of extra options. N)rZr,rX branch_name)rQrXr,rZs r(rPzRevOptions.__init__s2  J$  *.r*c2d|jjd|jdS)Nz )rXrr,rQs r(__repr__zRevOptions.__repr__s"Edm0EEEEEEr*c6|j |jjS|jSrN)r,rXdefault_arg_revr_s r(arg_revzRevOptions.arg_revs 8 =0 0xr*cjg}|j}|||j|z }||jz }|S)z< Return the VCS-specific command arguments. )rcrXget_base_rev_argsrZ)rQargsr,s r(to_argszRevOptions.to_argss@l ? DM33C88 8D  r*c*|jsdSd|jdS)Nz (to revision )r,r_s r( to_displayzRevOptions.to_displays$x 2+++++r*cD|j||jS)z Make a copy of the current instance, but with a new rev. Args: rev: the name of the revision for the new object. rZ)rXmake_rev_optionsrZ)rQr,s r(make_newzRevOptions.make_news!}--cdo-NNNr*NN)rFrGrH__doc__r r rSrrPr`propertyrcrgrlrprIr*r(rWrWws",0 //'(/c]/[) /  ////(F#FFFF#X     ,C,,,, OCOLOOOOOOr*rWcXeZdZUiZeedfed<gdZdfd Zde efdZ e de dfdZ e de efd Ze de efd Zd edddfd Zd eddfdZdededfdZdededfdZd ededfdZxZS) VcsSupportrY _registry)sshgithgbzrsftpsvnr Nctjj|jt dSrN)urllibparse uses_netlocextendschemesrOrP)rQrRs r(rPzVcsSupport.__init__s<   '' 555 r*c4|jSrN)rv__iter__r_s r(rzVcsSupport.__iter__s~&&(((r*cNt|jSrN)listrvvaluesr_s r(backendszVcsSupport.backendssDN))++,,,r*c$d|jDS)Ncg|] }|j SrI)r<).0backends r( z'VcsSupport.dirnames..s===G===r*)rr_s r(dirnameszVcsSupport.dirnamess==t}====r*cRg}|jD]}||j|SrN)rrr)rQrrs r(r&zVcsSupport.all_schemess4} , ,G NN7? + + + +r*clsct|ds"td|jdS|j|jvr9||j|j<td|jdSdS)NrzCannot register VCS %szRegistered VCS backend: %s)hasattrr=r>rFrrvdebug)rQrs r(registerzVcsSupport.registersxsF##  NN3S\ B B B F 84> ) )'*suuDN38 $ LL5sx @ @ @ @ @ * )r*rc,||jvr |j|=dSdSrN)rvrQrs r( unregisterzVcsSupport.unregisters' 4> ! !t$$$ " !r*r7ci}|jD]@}||}|std||j|||<A|sdSt |t}||S)zv Return a VersionControl object if a repository of that type is found at the given directory. zDetermine that %s uses VCS: %sN)key)rvrget_repository_rootr=rrmaxlen)rQr7 vcs_backends vcs_backend repo_pathinner_most_repo_paths r(get_backend_for_dirzVcsSupport.get_backend_for_dirs  >0022 2 2K#77AAI  LL98[EU V V V&1L # # 4 #0022 # #K,,,""""-tr*c^|}|j|S)r)lowerrvgetrs r( get_backendzVcsSupport.get_backends'zz||~!!$'''r*)r N)rFrGrHrvrrS__annotations__rrPrrrsrrrr&r rrr rrrrTrUs@r(rurus-/ItC))*///888G )(3-))))-$/0---X->$s)>>>X>T#YX AD!12AtAAAA%s%t%%%%2C2H=M4N2222.SX>N5O((1A(B((((((((r*ruceZdZUdZdZdZdZeedfe d<dZ eedfe d<dZ e ee d<e ded efd Ze d ed e efd Ze d ed efdZe d eded efdZeded eefdZdeded efdZe dBde ede ed efdZe ded efdZe deded eeee ee efffdZe ded eee eeffdZede ede ed efd Zded eeeffd!Z eded efd"Z!e d#ed$ed efd%Z"deded&ed dfd'Z#deded&ed dfd(Z$deded&ed dfd)Z%e ded*e ed efd+Z&deded dfd,Z'd eded dfd-Z(e d ed efd.Z)e d ed efd/Z*e dCd3e+eeefd4ed5e ed6d7d8e e,e-d9e ed:e e.ee/fd;e e0dZ1e d?ed efd@Z2e d ed e efdAZ3dS)DrYrirI.r unset_environNrb remote_urlr cb||jd S)z Return whether the vcs prefix (e.g. "git+") should be added to a repository's remote url when used in a requirement. :)r startswithr)rrs r(should_add_vcs_url_prefixz(VersionControl.should_add_vcs_url_prefixs/ ##%%00CH@@@@r*r7cdS)z Return the path to Python project root, relative to the repo root. Return None if the project root is in the repo root. NrIrr7s r(get_subdirectoryzVersionControl.get_subdirectorys tr*repo_dirc,||S)zR Return the revision string that should be used in a requirement. ) get_revision)rrs r(get_requirement_revisionz'VersionControl.get_requirement_revision's )))r*r-c||}||r |jd|}||}||}t ||||}|S)aC Return the requirement string to use to redownload the files currently at the given repository directory. Args: project_name: the (unescaped) project name. The return value has a form similar to the following: {repository_url}@{revision}#egg={project_name} +)r.)get_remote_urlrrrrr6)rrr-r+revisionr.r5s r(get_src_requirementz"VersionControl.get_src_requirement.s%%h//  ( ( 2 2 0(//X//H//99%%h//&x g((.. trw{++:tE{{:r*netlocr'c |dfS)aZ Parse the repository URL's netloc, and return the new netloc to use along with auth information. Args: netloc: the original repository URL netloc. scheme: the repository URL's scheme without the vcs prefix. This is mainly for the Subversion class to override, so that auth information can be provided via the --username and --password options instead of through the URL. For other subclasses like Git without such an option, auth information must stay in the URL. Returns: (netloc, (username, password)). rqrI)rrr's r(get_netloc_and_authz"VersionControl.get_netloc_and_authss&|##r*ctj|\}}}}}d|vr"td||ddd}|||\}}d}d|vr=|dd\}}|s"td|tj ||||df}|||fS)z Parse the repository URL to use, and return the URL, revision, and auth info to use. Returns: (url, rev, (username, password)). rzvSorry, {!r} is a malformed VCS url. The format is +://, e.g. svn+http://myrepo/svn/MyApp#egg=MyAppNr2zyThe URL {!r} has an empty revision (after @) which is not supported. Include a revision after @ or remove @ from the URL.ri) r~rurlsplit ValueErrorformatsplitrrsplitr urlunsplit) rrLr'rr;queryfrag user_passr,s r(get_url_rev_and_authz#VersionControl.get_url_rev_and_auths-3L,A,A#,F,F)eT f  ==CVC[[  c1%%a(33FFCC  $;; C++ID# '006s  l%%vvtUB&GHHC""r*usernamepasswordcgS)zM Return the RevOptions "extra arguments" to use in obtain(). rI)rrs r( make_rev_argszVersionControl.make_rev_argss  r*c||j\}}}|\}}d}|t|}|||}|||} t || fS)zq Return the URL and RevOptions object to use in obtain(), as a tuple (url, rev_options). Nrn)rsecretrrror) rQrL secret_urlr,rrsecret_passwordrrZ rev_optionss r(get_url_rev_optionsz"VersionControl.get_url_rev_optionss &*%>%>sz%J%J" C$-!/)-  &!/22H''(;; ++CJ+GG  ##[00r*cftj|dS)zi Normalize a URL for comparison by unquoting it and removing any trailing slash. /)r~runquoterstriprLs r( normalize_urlzVersionControl.normalize_urls( |##C((//444r*url1url2cZ||||kS)zV Compare two repo URLs for identity, ignoring incidental differences. )r)rrrs r( compare_urlszVersionControl.compare_urlss+   &&#*;*;D*A*AAAr*rct)z Fetch a revision from a repository, in the case that this is the first fetch from the repository. Args: dest: the directory to fetch the repository to. rev_options: a RevOptions object. rrQrrLrs r( fetch_newzVersionControl.fetch_new "!r*ct)z} Switch the repo at ``dest`` to point to ``URL``. Args: rev_options: a RevOptions object. rrs r(switchzVersionControl.switch "!r*ct)z Update an already-existing repo to the given ``rev_options``. Args: rev_options: a RevOptions object. rrs r(updatezVersionControl.updaterr*rct)z Return whether the id of the current commit equals the given name. Args: dest: the repository directory. name: a string name. r)rrrs r(is_commit_id_equalz!VersionControl.is_commit_id_equalrr*c||\}}tj|s||||dS|}||r'||}|||j rt d|j t|||||jsGtdt||j |||||ntddStd|j|j t||d}n)td||j|j d}td |j|t+d |d |d }|d krt/jd|dkrPtdt|t3|||||dS|dkrft5|}tdt||t7j||||||dS|dkrItd|j t|||||||dSdS)a Install or update in editable mode the package represented by this VersionControl object. :param dest: the repository directory in which to install or update. :param url: the repository URL starting with a vcs prefix. Nz)%s in %s exists, and has correct URL (%s)zUpdating %s %s%sz$Skipping because already up-to-date.z%s %s in %s exists with URL %s)z%(s)witch, (i)gnore, (w)ipe, (b)ackup )siwbz0Directory %s already exists, and is not a %s %s.)z(i)gnore, (w)ipe, (b)ackup )rrrz+The plan is to install the %s repository %szWhat to do? {}rrarz Deleting %srzBacking up %s to %srzSwitching %s %s to %s%s)rr:r;existsrrlis_repository_directoryrrrr=r repo_nametitlerrr,inforr>rrrsysexitrrshutilmover) rQrrLr rev_display existing_urlpromptresponsedest_dirs r(obtainzVersionControl.obtains* 33C88[w~~d##  NN4k 2 2 2 F!,,..  ' ' - -% F..t44L  sz::  ?N((** &&  ..t[_EE HKK*$T**#  KKc;7777KK FGGG NN0 T""    UFF NNB     FF 9 I    ##4#;#;F1I#F#Fq RR s?? HRLLL s?? NN=,t*<*< = = = 4LLL NN4k 2 2 2 F s??!$''H NN0,t2D2Dh O O O Kh ' ' ' NN4k 2 2 2 F s?? KK)T""     KKc; / / / / / ?r*ctj|rt||||dS)z Clean up current location and download the url repository (and vcs infos) into location :param url: the repository URL starting with a vcs prefix. rN)r:r;rrr)rQr7rLs r(unpackzVersionControl.unpackMsD 7>>( # #  8    H# &&&&&r*ct)z Return the url used at location Raises RemoteNotFoundError if the repository does not have a remote url configured. rrs r(rzVersionControl.get_remote_urlXrr*ct)zR Return the current commit id of the files at the given location. rrs r(rzVersionControl.get_revisionbs "!r*TraiseFcmd show_stdoutcwd on_returncodez"Literal["raise", "warn", "ignore"]extra_ok_returncodes command_desc extra_environspinnerlog_failed_cmd stdout_onlyc t|jg|R} t||||||||j|| |  S#t$r!t d|jd|jdt $rt d|jdwxYw)z Run a VCS subcommand This is simply a wrapper around call_subprocess that adds the VCS command name, and checks that the VCS is available )rrrrrrrrzCannot find command z - do you have z installed and in your PATH?zNo permission to execute z - install it locally, globally (ask admin), or check your PATH. See possible solutions at https://pip.pypa.io/en/latest/reference/pip_freeze/#fixing-permission-denied.)rrrrFileNotFoundErrorrPermissionError) rrrrrrrrrrrs r( run_commandzVersionControl.run_commandis&38*c*** "+%9)+!/-'    !   >>r*c4||r|SdS)ay Return the "root" (top-level) directory controlled by the vcs, or `None` if the directory is not in any. It is meant to be overridden to implement smarter detection mechanisms for specific vcs. This can do more than is_repository_directory() alone. For example, the Git override checks that Git is actually available. N)rrs r(rz"VersionControl.get_repository_roots$  & &x 0 0 Otr*rq) TNrNNNNTF)4rFrGrHrr<rrr rSrrrbr classmethodrrrrr staticmethodrrerrrWrorrAuthInforrrrrrrrrrrrrrr rintr rrr#rrrIr*r(rYrY s- DGI!GU38_!!!%'M5c?'''%)OXc])))A3A4AAA[A [*****[* 3cc[."s"tCy"""\" S      LP ; ;3- ;4<[4I ;  ; ; ;[ ;;;;;;[;$$"%$ sE(3-#677 8$$$[$(#s#uS(3-5Q/R###[#:3-+3J+? \ 1z 1eJ E8<&*59.2#!33 49k) *33c] 3 < 3 'x}5 3sm3 S 123*+333 333[3j?3?4???[? 3 8C=   [   r*rYrN)9rrloggingr:r r urllib.parser~typingrrrrrrr r r r r pip._internal.cli.spinnersrpip._internal.exceptionsrrpip._internal.utils.miscrrrrrrrrpip._internal.utils.subprocessrrrpip._internal.utils.urlsrr__all__ getLoggerrFr=rSr)rr)r6rC ExceptionrErKrWrurrYrIr*r(r6s{//                           877777BBBBBBBB                    VUUUUUUUUU333333 '  8 $ $ # - .HHHHHHIM+.8@ $00!0 c]0000:     )   ) @O@O@O@O@O@O@O@OFM(M(M(M(M(M(M(M(`jllhhhhhhhhhhr*