zmc
2023-12-22 9fdbf60165db0400c2e8e6be2dc6e88138ac719a
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
U
H=®d@ã@sÄdZddlZddlZddlZddlmZddlmZmZddl    m
Z
ddl m Z m Z ddlmZddlmZmZdd    lmZdd
lmZdd lmZdd lmZdd lmZddlmZddlm Z m!Z!ddl"m#Z#ddl$m%Z%ddl&m'Z'm(Z(e#r"ddl)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/ddl0m1Z1dddgZ2e 3e4¡Z5e
j6 7¡Z8dd„Z9dd„Z:dd„Z;dd„Z<dd „Z=Gd!d"„d"e>ƒZ?d#d$„Z@d2d&d„ZAd'd(„ZBd)d*„ZCd+d,„ZDd3d-d„ZEd4d.d/„ZFd5d0d1„ZGdS)6a~Backing implementation for InstallRequirement's various constructors
 
The idea here is that these formed a major chunk of InstallRequirement's size
so, moving them and support code dedicated to them outside of that class
helps creates for better understandability for the rest of the code.
 
These are meant to be used elsewhere within pip to create instances of
InstallRequirement.
éN)ÚMarker)ÚInvalidRequirementÚ Requirement)Ú    Specifier)ÚRequirementParseErrorÚparse_requirements)ÚInstallationError)ÚPyPIÚTestPyPI)ÚLink)ÚWheel)Úmake_pyproject_path)ÚInstallRequirement)Ú
deprecated)ÚARCHIVE_EXTENSIONS)Úis_installable_dirÚsplitext)ÚMYPY_CHECK_RUNNING)Ú path_to_url)Úis_urlÚvcs)ÚAnyÚDictÚOptionalÚSetÚTupleÚUnion)ÚParsedRequirementÚinstall_req_from_editableÚinstall_req_from_lineÚparse_editablecCs t|ƒd ¡}|tkrdSdS)z9Return True if `name` is a considered as an archive file.éTF)rÚlowerr)ÚnameÚext©r%úUD:\z\workplace\VsCode\pyvenv\venv\Lib\site-packages\pip/_internal/req/constructors.pyÚis_archive_file1sr'cCs6t d|¡}d}|r*| d¡}| d¡}n|}||fS)Nz^(.+)(\[[^\]]+\])$r!é)ÚreÚmatchÚgroup)ÚpathÚmÚextrasÚpath_no_extrasr%r%r&Ú _strip_extras:s 
 r0cCs|s
tƒStd| ¡ƒjS)NÚ placeholder)Úsetrr"r.)r.r%r%r&Úconvert_extrasGsr3c Csh|}t|ƒ\}}tj |¡rptj tj |d¡¡shd tj |¡¡}t|ƒ}tj     |¡r`|d7}t
|ƒ‚t |ƒ}|  ¡  d¡r°t|ƒj}|r¤||td|  ¡ƒjfS||tƒfStD](}|  ¡  d |¡¡r´d ||¡}qÞq´d|krôt
d     |¡ƒ‚| dd
¡d   ¡}t |¡s>d  d d„tjDƒ¡}    d ||    ¡}
t
|
ƒ‚t|ƒj}|s\t
d |¡ƒ‚||tƒfS)aParses an editable requirement into:
        - a requirement name
        - an URL
        - extras
        - editable options
    Accepted requirements:
        svn+http://blahblah@rev#egg=Foobar[baz]&subdirectory=version_subdir
        .[some_extra]
    zsetup.pyzMFile "setup.py" not found. Directory cannot be installed in editable mode: {}zb
(A "pyproject.toml" file was found, but editable mode currently requires a setup.py based build.)zfile:r1z{}:z{}+{}ú+z{} is not a valid editable requirement. It should either be a path to a local project or a VCS URL (beginning with svn+, git+, hg+, or bzr+).r!rz, cSsg|]}|jd‘qS)z+URL©r#)Ú.0Úbendsr%r%r&Ú
<listcomp>Šsz"parse_editable.<locals>.<listcomp>z2For --editable={}, only {} are currently supportedzZCould not detect requirement name for '{}', please specify one with #egg=your_package_name)r0Úosr,ÚisdirÚexistsÚjoinÚformatÚabspathr Úisfilerrr"Ú
startswithr Ú egg_fragmentrr.r2rÚsplitÚ get_backendÚbackends) Ú editable_reqÚurlÚ url_no_extrasr.ÚmsgÚpyproject_pathÚ package_nameÚversion_controlÚvc_typerDÚ error_messager%r%r&r Nsb   
ÿÿ ÿ
ý  þÿ þ
ÿÿc    Cs†d}tj |¡rtd}z8t|dƒ$}tt| ¡ƒƒ|d |¡7}W5QRXWq‚tk
rpt    j
d|ddYq‚Xn|d |¡7}|S)    z„Returns helpful msg in case requirements file does not exist,
    or cannot be parsed.
 
    :params req: Requirements file path
    Úz It does exist.Úrz•The argument you provided ({}) appears to be a requirements file. If that is the case, use the '-r' flag to install the packages specified within it.z&Cannot parse '%s' as requirements fileT)Úexc_infoz File '{}' does not exist.) r9r,r;ÚopenÚnextrÚreadr=rÚloggerÚdebug)ÚreqrHÚfpr%r%r&Údeduce_helpful_msg™s&  ÿúÿrXc@seZdZdd„ZdS)ÚRequirementPartscCs||_||_||_||_dS©N)Ú requirementÚlinkÚmarkersr.)Úselfr[r\r]r.r%r%r&Ú__init__¹szRequirementParts.__init__N)Ú__name__Ú
__module__Ú __qualname__r_r%r%r%r&rY¸srYcCsbt|ƒ\}}}|dk    rHz t|ƒ}WqLtk
rDtd |¡ƒ‚YqLXnd}t|ƒ}t||d|ƒS)NúInvalid requirement: '{}')r rrrr=r rY)rEr#rFÚextras_overriderVr\r%r%r&Úparse_req_from_editableÆs reFcCs^t|ƒ}t|j||d|j||||r.| dg¡ng|r@| dg¡ng|rR| di¡ni|jd S)NTÚinstall_optionsÚglobal_optionsÚhashes) Ú
comes_fromÚ user_suppliedÚeditabler\Ú
constraintÚ
use_pep517ÚisolatedrfrgÚ hash_optionsr.)rerr[r\Úgetr.)rErirmrnÚoptionsrlrjÚpartsr%r%r&rÚs ôcCs>tjj|krdStjjdk    r,tjj|kr,dS| d¡r:dSdS)akChecks whether the string "looks like" a path on the filesystem.
 
    This does not check whether the target actually exists, only judge from the
    appearance.
 
    Returns true if any of the following conditions is true:
    * a path separator is found (either os.path.sep or os.path.altsep);
    * a dot is found (which represents the current directory).
    TNÚ.F)r9r,ÚsepÚaltsepr@r5r%r%r&Ú_looks_like_path÷s 
rvcCs’t|ƒr6tj |¡r6t|ƒr$t|ƒStdjftƒŽƒ‚t    |ƒsBdStj 
|¡rVt|ƒS|  dd¡}t |ƒdkr~t|dƒs~dSt  d|¡t|ƒS)ad
    First, it checks whether a provided path is an installable directory
    (e.g. it has a setup.py). If it is, returns the path.
 
    If false, check if the path is an archive file (such as a .whl).
    The function checks if the path is a file. If false, if the path has
    an @, it will treat it as a PEP 440 URL requirement and return the path.
    zUDirectory {name!r} is not installable. Neither 'setup.py' nor 'pyproject.toml' found.Nú@r!r(rzARequirement %r looks like a filename, but the file does not exist)rvr9r,r:rrrr=Úlocalsr'r?rBÚlenrTÚwarning)r,r#Ú urlreq_partsr%r%r&Ú_get_url_from_path s(
ÿÿ  ýr|cst|ƒrd}nd}||krF| |d¡\}}| ¡}|s<d}qJt|ƒ}nd}| ¡}d‰tj tj |¡¡}d}d}t|ƒr„t|ƒ}n&t    |ƒ\}}t
||ƒ}    |    dk    rªt|    ƒ}|r|j dkræt   d|j¡rætttj tj |j¡¡ƒƒ}|jrt|jƒ}
djftƒŽ‰n|j‰n|‰t|ƒ} ‡fdd„} ˆdk    r z tˆƒ} WnŒtk
rÊtjjˆkrpd    }|tˆƒ7}n,d
ˆkr˜t‡fd d „tDƒƒs˜d }nd}| d ˆ¡ƒ}|r¾|d |¡7}t|ƒ‚Yn@X| jD]6}t|ƒ}|  d¡rÒd |¡}d}t!||ddqÒnd} t"| ||| ƒS)Nz; ú;r!Úfilez\.\./z{wheel.name}=={wheel.version}csˆs|Sd |ˆ¡S)Nz {} (from {}))r=)Útext)Ú line_sourcer%r&Ú with_source_sz(parse_req_from_line.<locals>.with_sourcezIt looks like a path.ú=c3s|]}|ˆkVqdSrZr%)r6Úop)Ú req_as_stringr%r&Ú    <genexpr>msz&parse_req_from_line.<locals>.<genexpr>z,= is not a valid operator. Did you mean == ?rNzInvalid requirement: {!r}z    
Hint: {}ú]zExtras after version '{}'.z+moving the extras before version specifiersz21.0)Ú replacementÚgone_in)#rrBÚstriprr9r,Únormpathr>r r0r|Úschemer)ÚsearchrFrÚis_wheelr Úfilenamer=rxrAr3rrrtrXÚanyÚ    operatorsrÚ    specifierÚstrÚendswithrrY)r#r€Ú
marker_sepÚmarkers_as_stringr]r,r\Úextras_as_stringÚprFÚwheelr.rrVÚadd_msgrHÚspecÚspec_strÚreplacer%)r€r„r&Úparse_req_from_line-sv
 
 
ÿ
 
 
ÿÿ
 
rc    Csbt||ƒ}t|j||j|j|||r.| dg¡ng|r@| dg¡ng|rR| di¡ni||j|d S)aCreates an InstallRequirement from a name, which might be a
    requirement, directory containing 'setup.py', filename, or URL.
 
    :param line_source: An optional string describing where the line is from,
        for logging purposes in case of an error.
    rfrgrh)
r\r]rmrnrfrgrorlr.rj)rrr[r\r]rpr.)    r#rirmrnrqrlr€rjrrr%r%r&rˆs
øcCs|z t|ƒ}Wn"tk
r.td |¡ƒ‚YnXtjtjg}|jrj|rj|jrj|jj    |krjtd |j
|¡ƒ‚t |||||dS)NrczkPackages installed from PyPI cannot depend on packages which are not also hosted on PyPI.
{} depends on {} )rnrmrj) rrrr=r    Úfile_storage_domainr
rFr\Únetlocr#r)Ú
req_stringrirnrmrjrVÚdomains_not_allowedr%r%r&Úinstall_req_from_req_string§s. þ
ÿþÿûr¢c
CsH|jr"t|j|j||j||d}n"t|j|j|||j|j|j|d}|S)N)rirmrlrnrj)rirmrnrqrlr€rj)Ú is_editablerr[rirlrrqr€)Ú
parsed_reqrnrmrjrVr%r%r&Ú#install_req_from_parsed_requirementÊs(ú
ø
r¥)NNFNFF)NNFNFNF)NFNF)FNF)HÚ__doc__Úloggingr9r)Zpip._vendor.packaging.markersrZ"pip._vendor.packaging.requirementsrrZ pip._vendor.packaging.specifiersrZpip._vendor.pkg_resourcesrrÚpip._internal.exceptionsrÚpip._internal.models.indexr    r
Úpip._internal.models.linkr Úpip._internal.models.wheelr Úpip._internal.pyprojectr Zpip._internal.req.req_installrÚpip._internal.utils.deprecationrÚpip._internal.utils.filetypesrÚpip._internal.utils.miscrrÚpip._internal.utils.typingrÚpip._internal.utils.urlsrÚpip._internal.vcsrrÚtypingrrrrrrZpip._internal.req.req_filerÚ__all__Ú    getLoggerr`rTÚ
_operatorsÚkeysrr'r0r3r rXÚobjectrYrerrvr|rrr¢r¥r%r%r%r&Ú<module>s|
             þ
 
     Kù
"]ø
!û
%ü