zmc
2023-10-12 ed135d79df12a2466b52dae1a82326941211dcc9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
U
H=®dneã@s¼dZddlmZddlZddlZddlZddlZddlZddlZddl    m
Z
ddl m Z ddlmZmZmZddlmZmZddlmZdd    lmZmZmZmZmZmZdd
lmZm Z m!Z!m"Z"dd l#m$Z$dd l%m&Z&e$r>dd l'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2ddlm3Z3ddlm4Z4e.e,e5e,e5fZ6dgZ7e 8e9¡Z:dd„Z;d"dd„Z<d#dd„Z=dd„Z>Gdd„de?ƒZ@Gdd„deAƒZBGdd„deAƒZCeCƒZDGd d!„d!eAƒZEdS)$z)Handles all VCS (version control) supporté)Úabsolute_importN)Ú pkg_resources)Úparse)Ú
BadCommandÚInstallationErrorÚSubProcessError)Úconsole_to_strÚsamefile)Úsubprocess_logger)Úask_path_existsÚ
backup_dirÚ display_pathÚhide_urlÚ
hide_valueÚrmtree)Úformat_command_argsÚ make_commandÚmake_subprocess_output_errorÚreveal_command_args)ÚMYPY_CHECK_RUNNING)Úget_url_scheme) ÚDictÚIterableÚIteratorÚListÚOptionalÚTextÚTupleÚTypeÚUnionÚMappingÚAny)Ú
HiddenText)Ú CommandArgsÚvcscCs*t|ƒ}|dkrdS|ddddgtjkS)z3
    Return true if the name looks like a URL.
    NFÚhttpÚhttpsÚfileÚftp)rr$Ú all_schemes)ÚnameÚscheme©r,úWD:\z\workplace\VsCode\pyvenv\venv\Lib\site-packages\pip/_internal/vcs/versioncontrol.pyÚis_url8sr.cCs.t |¡}d |||¡}|r*|d |¡7}|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={})rÚ to_filenameÚformat)Úrepo_urlÚrevÚ project_nameÚsubdirÚegg_project_nameÚreqr,r,r-Úmake_vcs_requirement_urlCs
    
r7Tc
Cs^|dkr g}tj}tj ¡}|r*| |¡d}t|ƒ}z.tjt    |ƒtj
tj
|d}    |    j rb|    j   ¡Wn6t k
rš}
z|rˆt d|
|¡‚W5d}
~
XYnXg} d} |    jr¸t|    j ¡ƒ} | s¾qÞ|  ¡} |  | d¡|| ƒq z |     ¡W5|    jrü|    j  ¡X|    jo|    j|k} | rT|s>|r>t||| |    jd}t |¡d |    j|¡}t|ƒ‚d | ¡S)    zõ
    Args:
      extra_ok_returncodes: an iterable of integer return codes that are
        acceptable, in addition to 0. Defaults to None, which means [].
      log_failed_cmd: if false, failed commands are not logged,
        only raised.
    NT)ÚstdoutÚstderrÚcwdz#Error %s while executing command %sÚ
)Úcmd_argsr:ÚlinesÚ exit_statuszSCommand errored out with exit status {}: {} Check the logs for full command output.Ú)r
ÚdebugÚosÚenvironÚcopyÚupdaterÚ
subprocessÚPopenrÚPIPEÚstdinÚcloseÚ    ExceptionÚcriticalr8rÚreadlineÚrstripÚappendÚwaitÚ
returncoderÚerrorr0rÚjoin)Úcmdr:Ú extra_environÚextra_ok_returncodesÚlog_failed_cmdÚlog_subprocessÚenvÚshowing_subprocessÚ command_descÚprocÚexcÚ
all_outputÚlineÚproc_had_errorÚmsgÚexc_msgr,r,r-Úcall_subprocessTsp
 
ûÿ
  ÿ ü
ÿýrbcCs`|}tj tj |d¡¡sD|}tj |¡}||krt d|¡dSqt||ƒrRdStj ||¡S)zÔ
    Find the path to `setup.py` by searching up the filesystem from `location`.
    Return the path to `setup.py` relative to `repo_root`.
    Return None if `setup.py` is in `repo_root` or cannot be found.
    zsetup.pyzGCould not find setup.py for directory %s (tried all parent directories)N)    rAÚpathÚexistsrRÚdirnameÚloggerÚwarningr    Úrelpath)ÚlocationÚ    repo_rootÚ orig_locationÚ last_locationr,r,r-Ú!find_path_to_setup_from_repo_rootªs ý
rmc@s eZdZdS)ÚRemoteNotFoundErrorN)Ú__name__Ú
__module__Ú __qualname__r,r,r,r-rnÆsrnc@sFeZdZdZddd„Zdd„Zedd„ƒZd    d
„Zd d „Z    d d„Z
dS)Ú
RevOptionsz¢
    Encapsulates a VCS-specific revision to install, along with any VCS
    install options.
 
    Instances of this class should be treated as if immutable.
    NcCs(|dkr 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)Ú
extra_argsr2Úvc_classÚ branch_name)Úselfrtr2rsr,r,r-Ú__init__Ós zRevOptions.__init__cCsd |jj|j¡S)Nz<RevOptions {}: rev={!r}>)r0rtr*r2©rvr,r,r-Ú__repr__èszRevOptions.__repr__cCs|jdkr|jjS|jS©N)r2rtÚdefault_arg_revrxr,r,r-Úarg_revìs
zRevOptions.arg_revcCs0g}|j}|dk    r"||j |¡7}||j7}|S)z<
        Return the VCS-specific command arguments.
        N)r|rtÚget_base_rev_argsrs)rvÚargsr2r,r,r-Úto_argsôs 
zRevOptions.to_argscCs|js
dSd |j¡S)Nr?z (to revision {}))r2r0rxr,r,r-Ú
to_displayszRevOptions.to_displaycCs|jj||jdS)z•
        Make a copy of the current instance, but with a new rev.
 
        Args:
          rev: the name of the revision for the new object.
        ©rs)rtÚmake_rev_optionsrs)rvr2r,r,r-Úmake_newszRevOptions.make_new)NN) rorprqÚ__doc__rwryÚpropertyr|rr€rƒr,r,r,r-rrÊs
 
 rrcs„eZdZiZddddddgZ‡fdd„Zd    d
„Zed d „ƒZed d„ƒZ    edd„ƒZ
dd„Z dd„Z dd„Z dd„Zdd„Z‡ZS)Ú
VcsSupportÚsshÚgitÚhgÚbzrÚsftpÚsvncs:tj |j¡ttddƒr(tj |j¡tt|ƒ ¡dS)NÚ uses_fragment)    Ú urllib_parseÚ uses_netlocÚextendÚschemesÚgetattrrÚsuperr†rwrx©Ú    __class__r,r-rws zVcsSupport.__init__cCs
|j ¡Srz)Ú    _registryÚ__iter__rxr,r,r-r—!szVcsSupport.__iter__cCst|j ¡ƒSrz)Úlistr–Úvaluesrxr,r,r-Úbackends%szVcsSupport.backendscCsdd„|jDƒS)NcSsg|]
}|j‘qSr,)re)Ú.0Úbackendr,r,r-Ú
<listcomp>-sz'VcsSupport.dirnames.<locals>.<listcomp>)ršrxr,r,r-Údirnames*szVcsSupport.dirnamescCs g}|jD]}| |j¡q
|Srz)ršrr‘)rvr‘rœr,r,r-r)/s
zVcsSupport.all_schemescCsHt|dƒst d|j¡dS|j|jkrD|ƒ|j|j<t d|j¡dS)Nr*zCannot register VCS %szRegistered VCS backend: %s)Úhasattrrfrgror*r–r@)rvÚclsr,r,r-Úregister7s 
 zVcsSupport.registercCs||jkr|j|=dSrz)r–©rvr*r,r,r-Ú
unregister@s
zVcsSupport.unregistercCsXi}|j ¡D],}| |¡}|s"qt d||j¡|||<q|sDdSt|td}||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)r–r™Úget_repository_rootrfr@r*ÚmaxÚlen)rvriÚ vcs_backendsÚ vcs_backendÚ    repo_pathÚinner_most_repo_pathr,r,r-Úget_backend_for_dirEs
ÿ
 zVcsSupport.get_backend_for_dircCs&|j ¡D]}||jkr
|Sq
dS)ú9
        Return a VersionControl object or None.
        N)r–r™r‘)rvr+r©r,r,r-Úget_backend_for_scheme^s
 
z!VcsSupport.get_backend_for_schemecCs| ¡}|j |¡S)r­)Úlowerr–Úgetr¢r,r,r-Ú get_backendhszVcsSupport.get_backend)rorprqr–r‘rwr—r…ršržr)r¡r£r¬r®r±Ú __classcell__r,r,r”r-r†s
 
 
 
    
r†c@s@eZdZdZdZdZdZdZdZe    dd„ƒZ
e    dd„ƒZ e    dd    „ƒZ e    d
d „ƒZ ed d „ƒZdd„Ze    d9dd„ƒZe    dd„ƒZdd„Ze    dd„ƒZe    dd„ƒZedd„ƒZdd„Zedd„ƒZe    d d!„ƒZd"d#„Zd$d%„Zd&d'„Ze    d(d)„ƒZd*d+„Zd,d-„Ze    d.d/„ƒZ e    d0d1„ƒZ!e    d:d3d4„ƒZ"e    d5d6„ƒZ#e    d7d8„ƒZ$dS);ÚVersionControlr?r,NcCs| ¡ d |j¡¡ S)zŽ
        Return whether the vcs prefix (e.g. "git+") should be added to a
        repository's remote url when used in a requirement.
        z{}:)r¯Ú
startswithr0r*)r Ú
remote_urlr,r,r-Úshould_add_vcs_url_prefix~sz(VersionControl.should_add_vcs_url_prefixcCsdS)z~
        Return the path to setup.py, relative to the repo root.
        Return None if setup.py is in the repo root.
        Nr,©r rir,r,r-Úget_subdirectory‡szVersionControl.get_subdirectorycCs
| |¡S)zR
        Return the revision string that should be used in a requirement.
        )Ú get_revision)r Úrepo_dirr,r,r-Úget_requirement_revisionsz'VersionControl.get_requirement_revisioncCsV| |¡}|dkrdS| |¡r.d |j|¡}| |¡}| |¡}t||||d}|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}
        Nz{}+{})r4)Úget_remote_urlr¶r0r*r»r¸r7)r rºr3r1Úrevisionr4r6r,r,r-Úget_src_requirement˜s
 
 
 
ÿz"VersionControl.get_src_requirementcCst‚dS)z™
        Return the base revision arguments for a vcs command.
 
        Args:
          rev: the name of a revision to install.  Cannot be None.
        N©ÚNotImplementedError)r2r,r,r-r}´s    z VersionControl.get_base_rev_argscCsdS)aZ
        Return true if the commit hash checked out at dest matches
        the revision in url.
 
        Always return False, if the VCS does not support immutable commit
        hashes.
 
        This method does not check if there are local uncommitted changes
        in dest after checkout, as pip currently has no use case for that.
        Fr,)rvÚurlÚdestr,r,r-Úis_immutable_rev_checkout¿s z(VersionControl.is_immutable_rev_checkoutcCst|||dS)z
        Return a RevOptions object.
 
        Args:
          rev: the name of a revision to install.
          extra_args: a list of extra options.
        r)rr)r r2rsr,r,r-r‚Ís
zVersionControl.make_rev_optionscCs&tj |¡\}}| tjj¡p$t|ƒS)zy
           posix absolute paths start with os.path.sep,
           win32 ones start with drive (like c:\folder)
        )rArcÚ
splitdriver´ÚsepÚbool)r ÚrepoÚdriveÚtailr,r,r-Ú_is_local_repositoryÙsz#VersionControl._is_local_repositorycCst‚dS)zÑ
        Export the repository at the url to the destination location
        i.e. only download the files, without vcs informations
 
        :param url: the repository URL starting with a vcs prefix.
        Nr¿©rvrirÁr,r,r-ÚexportãszVersionControl.exportcCs|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)).
        )NNr,)r Únetlocr+r,r,r-Úget_netloc_and_authísz"VersionControl.get_netloc_and_authc    Cs–t |¡\}}}}}d|kr*td |¡ƒ‚| dd¡d}| ||¡\}}d}d|krx| dd¡\}}|sxtd |¡ƒ‚t ||||df¡}|||fS)z¢
        Parse the repository URL to use, and return the URL, revision,
        and auth info to use.
 
        Returns: (url, rev, (username, password)).
        ú+zvSorry, {!r} is a malformed VCS url. The format is <vcs>+<protocol>://<url>, e.g. svn+http://myrepo/svn/MyApp#egg=MyAppéNú@zyThe URL {!r} has an empty revision (after @) which is not supported. Include a revision after @ or remove @ from the URL.r?)    rŽÚurlsplitÚ
ValueErrorr0ÚsplitrÎÚrsplitrÚ
urlunsplit)    r rÁr+rÍrcÚqueryÚfragÚ    user_passr2r,r,r-Úget_url_rev_and_auths(    þÿþÿz#VersionControl.get_url_rev_and_authcCsgS)zM
        Return the RevOptions "extra arguments" to use in obtain().
        r,)ÚusernameÚpasswordr,r,r-Ú make_rev_args szVersionControl.make_rev_argsc
CsT| |j¡\}}}|\}}d}|dk    r.t|ƒ}| ||¡}|j||d}    t|ƒ|    fS)zŒ
        Return the URL and RevOptions object to use in obtain() and in
        some cases export(), as a tuple (url, rev_options).
        Nr)rÚÚsecretrrÝr‚r)
rvrÁÚ
secret_urlr2rÙrÛÚsecret_passwordrÜrsÚ rev_optionsr,r,r-Úget_url_rev_options(s z"VersionControl.get_url_rev_optionscCst |¡ d¡S)zi
        Normalize a URL for comparison by unquoting it and removing any
        trailing slash.
        ú/)rŽÚunquoterM©rÁr,r,r-Ú normalize_url8szVersionControl.normalize_urlcCs| |¡| |¡kS)zV
        Compare two repo URLs for identity, ignoring incidental differences.
        )ræ)r Úurl1Úurl2r,r,r-Ú compare_urlsAszVersionControl.compare_urlscCst‚dS)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.
        Nr¿©rvrÂrÁrár,r,r-Ú    fetch_newIs
zVersionControl.fetch_newcCst‚dS)z}
        Switch the repo at ``dest`` to point to ``URL``.
 
        Args:
          rev_options: a RevOptions object.
        Nr¿rêr,r,r-ÚswitchUszVersionControl.switchcCst‚dS)zŠ
        Update an already-existing repo to the given ``rev_options``.
 
        Args:
          rev_options: a RevOptions object.
        Nr¿rêr,r,r-rD_szVersionControl.updatecCst‚dS)z¬
        Return whether the id of the current commit equals the given name.
 
        Args:
          dest: the repository directory.
          name: a string name.
        Nr¿)r rÂr*r,r,r-Úis_commit_id_equalis
z!VersionControl.is_commit_id_equalc    CsÐ| |¡\}}tj |¡s,| |||¡dS| ¡}| |¡rÒ| |¡}| ||j    ¡r²t
  d|j   ¡t|ƒ|¡| ||j¡s¤t
 dt|ƒ|j |¡| |||¡n
t
 d¡dSt
 d|j|j t|ƒ|¡d}nt
 d||j|j ¡d}t
 d    |j|¡td
 |d ¡|d ƒ}|d kr&t d¡|dkrZt
 dt|ƒ¡t|ƒ| |||¡dS|dkrœt|ƒ}t
 dt|ƒ|¡t ||¡| |||¡dS|dkrÌt
 d|j t|ƒ||¡| |||¡dS)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 )ÚsÚiÚwÚbz0Directory %s already exists, and is not a %s %s.)z(i)gnore, (w)ipe, (b)ackup )rïrðrñz+The plan is to install the %s repository %szWhat to do?  {}rrÐÚaéÿÿÿÿrðz Deleting %srñzBacking up %s to %srîzSwitching %s %s to %s%s)rârArcrdrër€Úis_repository_directoryr¼rérÞrfr@Ú    repo_nameÚtitler rír2ÚinforDrgr*r r0ÚsysÚexitrr ÚshutilÚmoverì)    rvrÂrÁráÚ rev_displayÚ existing_urlÚpromptÚresponseÚdest_dirr,r,r-Úobtainus–     
 
üü
ûüýÿÿ
 
 
 
ÿ 
ûzVersionControl.obtaincCs&tj |¡rt|ƒ|j||d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.
        råN)rArcrdrrrËr,r,r-ÚunpackÓs zVersionControl.unpackcCst‚dS)z–
        Return the url used at location
 
        Raises RemoteNotFoundError if the repository does not have a remote
        url configured.
        Nr¿r·r,r,r-r¼ßs    zVersionControl.get_remote_urlcCst‚dS)zR
        Return the current commit id of the files at the given location.
        Nr¿r·r,r,r-r¹êszVersionControl.get_revisionTc
Csnt|jf|žŽ}zt|||||dWStk
rh}z&|jtjkrVtdjftƒŽƒ‚n‚W5d}~XYnXdS)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
        )rTrUrVzWCannot find command {cls.name!r} - do you have {cls.name!r} installed and in your PATH?N)    rr*rbÚOSErrorÚerrnoÚENOENTrr0Úlocals)r rSr:rTrUrVÚer,r,r-Ú run_commandòsý þÿzVersionControl.run_commandcCs,t d||j|j¡tj tj ||j¡¡S)zL
        Return whether a directory path is a repository directory.
        zChecking in %s for %s (%s)...)rfr@rer*rArcrdrR)r rcr,r,r-rôs ÿz&VersionControl.is_repository_directorycCs| |¡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)rôr·r,r,r-r¥s
z"VersionControl.get_repository_root)NN)NNNT)%rorprqr*rerõr‘Ú unset_environr{Ú classmethodr¶r¸r»r¾Ú staticmethodr}rÃr‚rÊrÌrÎrÚrÝrârærérërìrDrírrr¼r¹rrôr¥r,r,r,r-r³tsl
 
 
 
 
 
 
    
 
 
 
 
 
 
 
 
^ 
 
 
ú 
    r³)N)NNNT)Fr„Ú
__future__rrÚloggingrArúrErøÚ pip._vendorrZpip._vendor.six.moves.urllibrrŽÚpip._internal.exceptionsrrrÚpip._internal.utils.compatrr    Úpip._internal.utils.loggingr
Úpip._internal.utils.miscr r r rrrÚpip._internal.utils.subprocessrrrrÚpip._internal.utils.typingrÚpip._internal.utils.urlsrÚtypingrrrrrrrrrr r!r"r#ÚstrZAuthInfoÚ__all__Ú    getLoggerrorfr.r7rbrmrJrnÚobjectrrr†r$r³r,r,r,r-Ú<module>sH       4  
 
û
VI^