7iY dZddlZddlZddlZddlZddlZddlmZm Z m Z m Z m Z m Z mZmZmZmZmZddlmZddlmZmZddlmZmZmZmZmZmZmZm Z ddl!m"Z"m#Z#m$Z$m%Z%ddl&m'Z'erdd lm(Z(d gZ)ejTe+Z,eee-ee-fZ.d e-d e/fd Z0 d de-de-de-dee-d e-f dZ1de-de-d ee-fdZ2Gdde3Z4Gdde3Z5GddZ6GddZ7e7Z8GddZ9y)!z)Handles all VCS (version control) supportN) TYPE_CHECKINGAnyDictIterableIteratorListMappingOptionalTupleTypeUnion)SpinnerInterface) BadCommandInstallationError) HiddenTextask_path_exists backup_dir display_pathhide_url hide_valueis_installable_dirrmtree) CommandArgscall_subprocessformat_command_args make_command)get_url_scheme)LiteralvcsnamereturncLt|}|y|gdtjzvS)z3 Return true if the name looks like a URL. F)httphttpsfileftp)rr all_schemes)r schemes i/mnt/ssd/data/python-lab/ChefSystem/venv/lib/python3.12/site-packages/pip/_internal/vcs/versioncontrol.pyis_urlr*9s+D !F ~ 5G GGrepo_urlrev project_namesubdircR|jdd}|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_urlr7CsH$++C5 JauE"2!3 4C  x(( Jr+location repo_rootc0|}t|sI|}tjj|}||k(rtj d|yt|sItjj ||rytjj||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)r8r9 orig_location last_locations r)(find_path_to_project_root_from_repo_rootrDUsM * 77??8, } $ NN&  !* ww 8, 77??8Y //r+c eZdZy)RemoteNotFoundErrorN)__name__ __module__ __qualname__r+r)rFrFrsr+rFc$eZdZdeffd ZxZS)RemoteNotValidErrorurlc2t||||_yN)super__init__rM)selfrM __class__s r)rQzRemoteNotValidError.__init__ws r+)rGrHrIstrrQ __classcell__rSs@r)rLrLvsCr+rLc eZdZdZ ddeddeedeeddfdZdefd Z e deefd Z defd Z defd Z deddfd Zy) 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!cD|g}||_||_||_d|_y)z Args: vc_class: a VersionControl subclass. rev: the name of the revision to install. extra_args: a list of extra options. N)r[r-rY branch_name)rRrYr-r[s r)rQzRevOptions.__init__s,  J$  *.r+cPd|jjd|jdS)Nz )rYr r-rRs r)__repr__zRevOptions.__repr__s&dmm001|1EEr+c^|j|jjS|jSrO)r-rYdefault_arg_revr`s r)arg_revzRevOptions.arg_revs% 88 ==00 0xxr+cg}|j}|||jj|z }||jz }|S)z< Return the VCS-specific command arguments. )rdrYget_base_rev_argsr[)rRargsr-s r)to_argszRevOptions.to_argssCll ? DMM33C8 8D  r+c<|jsyd|jdS)Nz (to revision )r-r`s r) to_displayzRevOptions.to_displaysxxz++r+cP|jj||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. r[)rYmake_rev_optionsr[)rRr-s r)make_newzRevOptions.make_news"}}--cdoo-NNr+NN)rGrHrI__doc__r r rTrrQrapropertyrdrhrmrqrJr+r)rXrX|s",0 /'(/c]/[) /  /(F#F#  ,C, OCOLOr+rXceZdZUiZeedfed<gdZdfd Zde efdZ e de dfdZ e de efd Ze de efd Zd edddfd Zd eddfdZdededfdZdededfdZd ededfdZxZS) VcsSupportrZ _registry)sshgithgbzrsftpsvnr!Nctjjj|jt |yrO)urllibparse uses_netlocextendschemesrPrQ)rRrSs r)rQzVcsSupport.__init__s,    '' 5 r+c6|jjSrO)rw__iter__r`s r)rzVcsSupport.__iter__s~~&&((r+cHt|jjSrO)listrwvaluesr`s r)backendszVcsSupport.backendssDNN))+,,r+cT|jDcgc]}|jc}Scc}wrO)rr=)rRbackends r)dirnameszVcsSupport.dirnamess/3}}=G===s%cbg}|jD]}|j|j|SrO)rrr)rRrrs r)r'zVcsSupport.all_schemess/}} ,G NN7?? + ,r+clsc t|ds!tjd|jy|j|j vr?||j |j<tj d|jyy)Nr zCannot register VCS %szRegistered VCS backend: %s)hasattrr>r?rGr rwdebug)rRrs r)registerzVcsSupport.registers^sF# NN3S\\ B  884>> )'*uDNN388 $ LL5sxx @ *r+r c<||jvr|j|=yyrO)rwrRr s r) unregisterzVcsSupport.unregisters 4>> !t$ "r+r8ci}|jjD]<}|j|}|stj d||j |||<>|syt |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)rwrget_repository_rootr>rr maxlen)rRr8 vcs_backends vcs_backend repo_pathinner_most_repo_paths r)get_backend_for_dirzVcsSupport.get_backend_for_dirs  >>002 2K#77AI LL98[EUEU V&1L #  2 #>002 #K,,,"" #r+cX|j}|jj|S)r)lowerrwgetrs r) get_backendzVcsSupport.get_backends$zz|~~!!$''r+)r!N)rGrHrIrwrrT__annotations__rrQrrrtrrrr'r rrr rrrrUrVs@r)rvrvs -/ItC))*/8G )(3-)-$/0-->$s)>>T#Y AD!12AtA%s%t%2C2H=M4N2.SX>N5O((1A(B(r+rvceZdZUdZdZdZdZeedfe 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 d@de 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'e#d df d(Z$deded&ed dfd)Z%deded&ed dfd*Z&e ded+e ed efd,Z'deded'e#d dfd-Z(d eded'e#d dfd.Z)e d ed efd/Z*e d ed efd0Z+e dAd1e,eeefd2ed3e ed4d5d6e e-e#d7e ed8e e.ee/fd9e e0d:ed;ed efd<Z1e d=ed efd>Z2e d ed e efd?Z3y)BrZrjrJ.r unset_environNrc remote_urlr!c\|jj|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+ ##%00CHH:Q@@@r+r8cy)z Return the path to Python project root, relative to the repo root. Return None if the project root is in the repo root. NrJrr8s r)get_subdirectoryzVersionControl.get_subdirectory$s r+repo_dirc$|j|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|j|}|j|r|jd|}|j|}|j |}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_urlrr rrr7)rrr.r,revisionr/r6s r)get_src_requirementz"VersionControl.get_src_requirement3sl%%h/  ( ( 2((1XJ/H//9%%h/&x+://, e.g. svn+http://myrepo/svn/MyApp#egg=MyAppNr3zThe URL zm has an empty revision (after @) which is not supported. Include a revision after @ or remove @ from the URL.rj) rrurlsplit ValueErrorsplitrrsplitr urlunsplit) rrMr(rr<queryfrag user_passr-s r)get_url_rev_and_authz#VersionControl.get_url_rev_and_auths-3LL,A,A#,F)eT f #!==  c1%a(33FFC  $; C+ID#'sg&00 ll%%vvtUB&GHC""r+usernamepasswordcgS)zM Return the RevOptions "extra arguments" to use in obtain(). rJ)rrs r) make_rev_argszVersionControl.make_rev_argss  r+c|j|j\}}}|\}}d}| t|}|j||}|j ||} t || fS)zq Return the URL and RevOptions object to use in obtain(), as a tuple (url, rev_options). Nro)rsecretrrrpr) rRrM secret_urlr-rrsecret_passwordrr[ rev_optionss r)get_url_rev_optionsz"VersionControl.get_url_rev_optionssu &*%>%>szz%J" C$-!/)-  &!/2H''(; ++CJ+G  #[00r+c^tjj|jdS)zi Normalize a URL for comparison by unquoting it and removing any trailing slash. /)rrunquoterstrip)rMs r) normalize_urlzVersionControl.normalize_urls$ ||##C(//44r+url1url2cH|j||j|k(S)zV Compare two repo URLs for identity, ignoring incidental differences. )r)rrrs r) compare_urlszVersionControl.compare_urlss%   &#*;*;D*AAAr+r verbosityct)a 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. verbosity: verbosity level. r)rRrrMrrs r) fetch_newzVersionControl.fetch_news "!r+ct)z} Switch the repo at ``dest`` to point to ``URL``. Args: rev_options: a RevOptions object. rrRrrMrs 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+r ct)z Return whether the id of the current commit equals the given name. Args: dest: the repository directory. name: a string name. r)rrr s r)is_commit_id_equalz!VersionControl.is_commit_id_equals "!r+c|j|\}}tjj|s|j ||||y|j }|j |r|j|}|j||jrtjd|jjt|||j||j s?tj#dt||j||j%|||ytj#dytj'd|j(|jt||d}n.tj'd||j(|jd }tj'd |j(|t+d |d |d }|dk(rt-j.d|dk(r@tj'dt|t1||j ||||y|dk(rWt3|} tj'dt|| t5j6|| |j ||||y|dk(r@tj#d|jt||||j9|||yy)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. :param verbosity: verbosity level. )rNz)%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 %sz What to do? rrarz Deleting %srzBacking up %s to %srzSwitching %s %s to %s%s)rr;r<existsrrmis_repository_directoryrrrr>r repo_nametitlerrr-inforr?r rsysexitrrshutilmover) rRrrMrr rev_display existing_urlpromptresponsedest_dirs r)obtainzVersionControl.obtainsr 33C8[ww~~d# NN4kYN G !,,.  ' ' -..t4L  szz: ?NN((* &  ..t[__EKK*$T*#  KKc;7KK FG NN0 T"  UF NNB   FF 9 II  #]6!9+#>q J s? HHRL s? NN=,t*< = 4L NN4kYN G  s?!$'H NN0,t2Dh O KKh ' NN4kYN G  s? KK)T"   KKc; / r+ctjj|r t||j |||y)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. :param verbosity: verbosity level. )rMrN)r;r<rrr )rRr8rMrs r)unpackzVersionControl.unpackVs. 77>>( # 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_urlbrr+ct)zR Return the current commit id of the files at the given location. rrs r)rzVersionControl.get_revisionls "!r+cmd show_stdoutcwd on_returncodez"Literal["raise", "warn", "ignore"]extra_ok_returncodes command_desc extra_environspinnerlog_failed_cmd stdout_onlyc 2t|jg|}| t|} 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.)rr rrrFileNotFoundErrorrPermissionError) rrrrrrrrrrrs r) run_commandzVersionControl.run_commandss&388*c*  .s3L "+%9)+!//-'  ! &sxxl/88,:<   +CHH<8-.  s AABr<ctjd||j|jtj j tj j||jS)zL Return whether a directory path is a repository directory. zChecking in %s for %s (%s)...)r>rr=r r;r<rjoin)rr<s r)rz&VersionControl.is_repository_directorysE  4dCKKRww~~bggll4=>>r+c*|j|r|Sy)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 0Or+rr) TNraiseNNNNTF)4rGrHrIr r=rrr rTrrrcr classmethodrrrrr staticmethodrrfrrrXrprrAuthInforrrrrrintrrrrr rrrr rr rrrrrrJr+r)rZrZs DGI!GU38_!%'M5c?'%)OXc])A3A4AA **** 3cc."s"tCy"" S   LP ;3- ;4<[4I ;  ; ;;;;;$$"%$ sE(3-#677 8$$(#s#uS(3-5Q/R##:3-+3J+?  1z 1eJ E8<&*59.2#!5 49k) *55c] 5 < 5 'x}5 5sm5 S 125*+555 55n?3?4?? 3 8C=  r+rZrO):rsloggingr;rr urllib.parsertypingrrrrrrr r r r r pip._internal.cli.spinnersrpip._internal.exceptionsrrpip._internal.utils.miscrrrrrrrrpip._internal.utils.subprocessrrrrpip._internal.utils.urlsrr__all__ getLoggerrGr>rTr%rr*r7rD ExceptionrFrLrXrvrrZrJr+r)r2sE/     8B    4 '   8 $ # - .HHHIM+.8@ $00!0 c]0: ) ) @O@OFM(M(`loor+