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
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
U
H=®døKã@sVdZddlmZddlZddlZddlZddlZddlZddlm    Z
ddl m Z ddl mZmZddlmZddlmZdd    lmZdd
lmZdd lmZerdd lmZdd lmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$ddl%m&Z&ddl'm(Z(ee$e)e#fZ*ee#ge$e+effZ,dgZ-e .dej/¡Z0e .d¡Z1e .d¡Z2e j3e j4e j5e j6e j7e j8e j9e j:e j;e j<e j=e j>e j?e j@gZAe jBe jCe jDgZEdd„eEDƒZFGdd„deGƒZHGdd„deGƒZId7dd„ZJdd„ZKd8dd„ZLd9d d!„ZMd:d"d#„ZNGd$d%„d%eGƒZOd&d'„ZPd(d)„ZQGd*d+„d+eRƒZSd,d-„ZTd.d/„ZUd0d1„ZVd2d3„ZWd;d4d5„ZXe .d6ej/¡ZYdS)<z
Requirements file parsing
é)Úabsolute_importN)Úparse)Ú
cmdoptions)ÚInstallationErrorÚRequirementsFileParseError)Ú SearchScope)Úraise_for_status)Ú auto_decode)ÚMYPY_CHECK_RUNNING)Úget_url_scheme)ÚValues)    ÚAnyÚCallableÚDictÚIteratorÚListÚNoReturnÚOptionalÚTextÚTuple)Ú PackageFinder)Ú
PipSessionÚparse_requirementsz^(http|https|file):z (^|\s+)#.*$z#(?P<var>\$\{(?P<name>[A-Z0-9_]+)\})cCsg|]}t|ƒjƒ‘qS©)ÚstrÚdest)Ú.0ÚorrúQD:\z\workplace\VsCode\pyvenv\venv\Lib\site-packages\pip/_internal/req/req_file.pyÚ
<listcomp>Lsrc@seZdZddd„ZdS)ÚParsedRequirementNcCs(||_||_||_||_||_||_dS©N)Ú requirementÚ is_editableÚ
comes_fromÚoptionsÚ
constraintÚ line_source)Úselfr"r#r$r&r%r'rrrÚ__init__Ps
zParsedRequirement.__init__)NN©Ú__name__Ú
__module__Ú __qualname__r)rrrrr Osùr c@seZdZdd„ZdS)Ú
ParsedLinecCs`||_||_||_||_||_|r6d|_d|_||_n&|jrVd|_d|_|jd|_nd|_dS)NTFr)    ÚfilenameÚlinenor$Úoptsr&Úis_requirementr#r"Ú    editables)r(r/r0r$Úargsr1r&rrrr)cs
zParsedLine.__init__Nr*rrrrr.bsr.Fc
csHt|ƒ}t|||ƒ}| ||¡D]"}t||||d}    |    dk    r |    Vq dS)a­Parse a requirements file and yield ParsedRequirement instances.
 
    :param filename:    Path or url of requirements file.
    :param session:     PipSession instance.
    :param finder:      Instance of pip.index.PackageFinder.
    :param comes_from:  Origin description of requirements.
    :param options:     cli options.
    :param constraint:  If true, parsing a constraint file rather than
        requirements file.
    )r%ÚfinderÚsessionN)Úget_line_parserÚRequirementsFileParserrÚ handle_line)
r/r6r5r$r%r&Ú line_parserÚparserÚ parsed_lineÚ
parsed_reqrrrr€s ücCs,t| ¡dd}t|ƒ}t|ƒ}t|ƒ}|S)zxSplit, filter, and join lines, and return a line iterator
 
    :param content: the content of the requirements file
    é)Ústart)Ú    enumerateÚ
splitlinesÚ
join_linesÚignore_commentsÚexpand_env_variables)ÚcontentÚ
lines_enumrrrÚ
preprocess¡s
rGcCs¸d |jrdnd|j|j¡}|js&t‚|jrBt|j|j||jdS|rTt     
||j ¡i}t D],}||j j kr\|j j |r\|j j |||<q\d |j|j¡}t|j|j||j||dSdS)Nz{} {} (line {})z-cz-r)r"r#r$r&ú line {} of {})r"r#r$r&r%r')Úformatr&r/r0r2ÚAssertionErrorr#r r"rÚcheck_install_build_globalr1ÚSUPPORTED_OPTIONS_REQ_DESTÚ__dict__)Úliner%Úline_comes_fromÚ req_optionsrr'rrrÚhandle_requirement_line®s8 ÿ
üúrQcs"ˆr4|jr|jˆ_|jr4ˆj ‡fdd„|jDƒ¡|r|j}|j}|jrT|jg}|jdkrbg}|jrt| |j¡|jrÀ|jd}tj     
tj      |¡¡}    tj      |    |¡}
tj      |
¡r¶|
}| |¡t||d} | |_|jrà| ¡|jrî| ¡|r|jpügD]} d ||¡} |j| | dqþdS)Nc3s|]}|ˆjkr|VqdSr!)Úfeatures_enabled)rÚf©r%rrÚ    <genexpr>és
ÿz%handle_option_line.<locals>.<genexpr>Tr)Ú
find_linksÚ
index_urlsrH)Úsource)Úrequire_hashesrRÚextendrVrWÚ    index_urlÚno_indexÚextra_index_urlsÚosÚpathÚdirnameÚabspathÚjoinÚexistsÚappendrÚ search_scopeÚpreÚset_allow_all_prereleasesÚ prefer_binaryÚset_prefer_binaryÚ trusted_hostsrIÚadd_trusted_host)r1r/r0r5r%r6rVrWÚvalueÚreq_dirÚrelative_to_reqs_filereÚhostrXrrTrÚhandle_option_lineÚsH
ÿ
 
 
þ rpcCs4|jrt||ƒ}|St|j|j|j|||ƒdSdS)aHandle a single parsed requirements line; This can result in
    creating/yielding requirements, or updating the finder.
 
    :param line:        The parsed line to be processed.
    :param options:     CLI options.
    :param finder:      The finder - updated by non-requirement lines.
    :param session:     The session - updated by non-requirement lines.
 
    Returns a ParsedRequirement object if the line is a requirement line,
    otherwise returns None.
 
    For lines that contain requirements, the only options that have an effect
    are from SUPPORTED_OPTIONS_REQ, and they are scoped to the
    requirement. Other options from SUPPORTED_OPTIONS may be present, but are
    ignored.
 
    For lines that do not contain requirements, the only options that have an
    effect are from SUPPORTED_OPTIONS. Options from SUPPORTED_OPTIONS_REQ may
    be present, but are ignored. These lines may contain multiple options
    (although our docs imply only one is supported), and all our parsed and
    affect the finder.
    N)r2rQrpr1r/r0)rNr%r5r6r=rrrr9s
úr9c@s,eZdZdd„Zdd„Zdd„Zdd„Zd    S)
r8cCs||_||_||_dSr!)Ú_sessionÚ _line_parserÚ _comes_from)r(r6r:r$rrrr)CszRequirementsFileParser.__init__ccs| ||¡D]
}|Vq dS)z3Parse a given file, yielding parsed lines.
        N)Ú_parse_and_recurse)r(r/r&rNrrrrNszRequirementsFileParser.parseccs®| ||¡D]œ}|js¢|jjs&|jjr¢|jjr@|jjd}d}n|jjd}d}t |¡rht ||¡}n t |¡sˆt    j
  t    j
  |¡|¡}|  ||¡D]
}|Vq”q |Vq dS)NrFT)Ú _parse_filer2r1Ú requirementsÚ constraintsÚ    SCHEME_REÚsearchÚ urllib_parseÚurljoinr^r_rbr`rt)r(r/r&rNÚreq_pathÚnested_constraintÚ
inner_linerrrrtUs2ÿþþ  
 
 
ÿÿ
z)RequirementsFileParser._parse_and_recursec cs’t||j|jd\}}t|ƒ}|D]j\}}z| |¡\}}    Wn8tk
rt}
zd ||
j¡} t| ƒ‚W5d}
~
XYnXt    |||j||    |ƒVq"dS)N)r$zInvalid requirement: {}
{})
Úget_file_contentrqrsrGrrÚOptionParsingErrorrIÚmsgrr.) r(r/r&Ú_rErFÚ line_numberrNÚargs_strr1Úerrrrruvs(ÿ
 úz"RequirementsFileParser._parse_fileN)r+r,r-r)rrtrurrrrr8Bs !r8cs‡fdd„}|S)Ncs^tƒ}| ¡}d|_ˆr ˆj|_t|ƒ\}}tjdkr@| d¡}| t     
|¡|¡\}}||fS)N)éééÚutf8) Ú build_parserÚget_default_valuesr[Úformat_controlÚbreak_args_optionsÚsysÚ version_infoÚencodeÚ
parse_argsÚshlexÚsplit)rNr;Údefaultsr„Ú options_strr1r‚©r5rrÚ
parse_line’s 
 
ÿz#get_line_parser.<locals>.parse_liner)r5r—rr–rr7s r7cCsf| d¡}g}|dd…}|D]2}| d¡s6| d¡r<qRq| |¡| d¡qd |¡d |¡fS)z½Break up the line into an args and options string.  We only want to shlex
    (and then optparse) the options, not the args.  args can contain markers
    which are corrupted by shlex.
    ú Nú-z--r)r“Ú
startswithrdÚpoprb)rNÚtokensr4r%Útokenrrrr«s
 
 rc@seZdZdd„ZdS)r€cCs
||_dSr!)r©r(rrrrr)¾szOptionParsingError.__init__Nr*rrrrr€½sr€cCs@tjdd}tt}|D]}|ƒ}| |¡qdd„}||_|S)z7
    Return a parser for parsing requirement lines
    F)Úadd_help_optioncSs t|ƒ‚dSr!)r€ržrrrÚ parser_exitÑsz!build_parser.<locals>.parser_exit)ÚoptparseÚ OptionParserÚSUPPORTED_OPTIONSÚSUPPORTED_OPTIONS_REQÚ
add_optionÚexit)r;Úoption_factoriesÚoption_factoryÚoptionr rrrrŠÃs  rŠccs´d}g}|D]‚\}}| d¡r(t |¡rvt |¡r:d|}|rj| |¡|dk    sTt‚|d |¡fVg}qŽ||fVq |s~|}| | d¡¡q |r°|dk    s t‚|d |¡fVdS)z’Joins a line ending in '' with the previous line (except when following
    comments).  The joined line takes on the index of the first line.
    Nú\r˜Ú)ÚendswithÚ
COMMENT_REÚmatchrdrJrbÚstrip)rFÚprimary_line_numberÚnew_linerƒrNrrrrBÛs$ 
 
   rBccs4|D]*\}}t d|¡}| ¡}|r||fVqdS)z1
    Strips comments and filter empty lines.
    r«N)r­Úsubr¯)rFrƒrNrrrrCûs
  rCccsL|D]B\}}t |¡D]$\}}t |¡}|s.q| ||¡}q||fVqdS)a«Replace all environment variables that can be retrieved via `os.getenv`.
 
    The only allowed format for environment variables defined in the
    requirement file is `${MY_VARIABLE_1}` to ensure two things:
 
    1. Strings that contain a `$` aren't accidentally (partially) expanded.
    2. Ensure consistency across platforms for requirement files.
 
    These points are the result of a discussion on the `github pull
    request #3514 <https://github.com/pypa/pip/pull/3514>`_.
 
    Valid characters in variable names follow the `POSIX standard
    <http://pubs.opengroup.org/onlinepubs/9699919799/>`_ and are limited
    to uppercase letter, digits and the `_` (underscore).
    N)Ú
ENV_VAR_REÚfindallr^ÚgetenvÚreplace)rFrƒrNÚenv_varÚvar_namerlrrrrDs 
rDc
 
Cs$t|ƒ}|dkr.| |¡}t|ƒ|j|jfS|dkrÂ|rT| d¡rTtd ||¡ƒ‚| dd¡d}|     dd¡}t
  |¡}|rœ|  d¡d| d    d¡d}t  |¡}| d¡r¾d| d¡}|}z&t|d
ƒ}t| ¡ƒ}W5QRXWn2tk
r}    ztd  |    ¡ƒ‚W5d }    ~    XYnX||fS) aZGets the content of a file; it may be a filename, file: URL, or
    http: URL.  Returns (location, content).  Content is unicode.
    Respects # -*- coding: declarations on the retrieved files.
 
    :param url:         File path or url.
    :param session:     PipSession instance.
    :param comes_from:  Origin description of requirements.
    )ÚhttpÚhttpsÚfiler¹z6Requirements file {} references URL {}, which is localú:r>rªú/ú|Úrbz$Could not open requirements file: {}N)r ÚgetrÚurlÚtextršrrIr“r¶Ú_url_slash_drive_rer®ÚgrouprzÚunquoteÚlstripÚopenr    ÚreadÚIOError)
rÁr6r$ÚschemeÚrespr_r®rSrEÚexcrrrr#s<
 
 ÿÿ 
 
 
 ÿrz /*([a-z])\|)NNNF)N)NNN)NNN)N)ZÚ__doc__Ú
__future__rr¡r^Úrer’rŽZpip._vendor.six.moves.urllibrrzZpip._internal.clirÚpip._internal.exceptionsrrÚ!pip._internal.models.search_scoperÚpip._internal.network.utilsrÚpip._internal.utils.encodingr    Úpip._internal.utils.typingr
Úpip._internal.utils.urlsr r Útypingr rrrrrrrrÚ"pip._internal.index.package_finderrÚpip._internal.network.sessionrÚintZ ReqFileLinesrZ
LineParserÚ__all__ÚcompileÚIrxr­r³r[Úextra_index_urlr\rwrvÚeditablerVÚ    no_binaryÚ only_binaryrhrYrfÚ trusted_hostÚuse_new_featurer£Úinstall_optionsÚglobal_optionsÚhashr¤rLÚobjectr r.rrGrQrpr9r8r7rÚ    Exceptionr€rŠrBrCrDrrÃrrrrÚ<module>s’         ,  
 
òý!ú
!þ
0ú
=ü
-N  
-