T4}:PUdZddlmZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl mZmZddlmZddlmZddlmZmZmZmZddlmZdd lmZmZdd lmZer dd lm Z dd l!m"Z"d gZ#ee$e%e&fZ'ee&ge$e&effZ(ej)dej*Z+ej)dZ,ej)dZ-ej.ej/ej0ej1ej2ej3ej4ej5ej6ej7ej8ej9ej:ej;gZej?gZ@de=d<ej?gZAde=d<de@DZBdeADZCejDdfejEdfejFdfejGdfejHdfejIdfejJdfgZKde=d<ej)d ZLdZMejNeOZPed!"Gd#d$ZQed!"Gd%d&ZR dVdWd4ZSdXd7ZT dYdZd9ZU d[d\d@ZV d[d]dBZWGdCdDZXd^dFZYd_dHZZGdIdJe[Z\d`dLZ]dadNZ^dadOZ_dadPZ`dbdRZadcdUZbdS)dz Requirements file parsing ) annotationsN) GeneratorIterable) dataclass)Values) TYPE_CHECKINGAnyCallableNoReturn) cmdoptions)InstallationErrorRequirementsFileParseError) SearchScope) PackageFinder) PipSessionparse_requirementsz^(http|https|file):z (^|\s+)#.*$z#(?P\$\{(?P[A-Z0-9_]+)\})z$list[Callable[..., optparse.Option]]SUPPORTED_OPTIONSSUPPORTED_OPTIONS_REQSUPPORTED_OPTIONS_EDITABLE_REQcFg|]}t|jSstrdest.0os l/builddir/build/BUILD/cloudlinux-venv-1.0.10/venv/lib/python3.11/site-packages/pip/_internal/req/req_file.py rNs&KKKc!!##(mmKKKcFg|]}t|jSrrrs rrrOs3'''CMM'''r zutf-8zutf-32z utf-32-bez utf-32-lezutf-16z utf-16-bez utf-16-lezlist[tuple[bytes, str]]BOMSscoding[:=]\s*([-\w.]+)T)frozencPeZdZUdZded<ded<ded<ded<ded <d ed <d S) ParsedRequirement requirement is_editable comes_from constraintoptions line_sourcerr'boolr(r)r*zdict[str, Any] | Noner+ str | Noner,N)__name__ __module__ __qualname__ __slots____annotations__rr rr%r%es`IOOO""""r r%cveZdZUdZded<ded<ded<ded<d ed <edd ZeddZdS) ParsedLine)filenamelinenoargsoptsr*rr6intr7r8rr9r-r*returnc4t|jjSN)r-r9 editablesselfs rr(zParsedLine.is_editablesDI'(((r r.cT|jr|jS|jr|jjdSdS)Nr)r8r(r9r>r?s rr'zParsedLine.requirements4 9 *9    *9&q) )tr N)r;r-)r;r.)r/r0r1r2r3propertyr(r'rr rr5r5ysDIMMMKKK IIILLL )))X)Xr r5Fr6rsessionrfinderPackageFinder | Noner+optparse.Values | Noner*r-r;(Generator[ParsedRequirement, None, None]c#Kt|}t||}|||D]}t||||}||VdS)aqParse 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 options: cli options. :param constraint: If true, parsing a constraint file rather than requirements file. )r+rDrCN)get_line_parserRequirementsFileParserparse handle_line) r6rCrDr+r* line_parserparser parsed_line parsed_reqs rrrs} "&))K #G[ 9 9F||Hj99       !    r content ReqFileLinesct|d}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_linesignore_commentsexpand_env_variables)rQ lines_enums r preprocessr\sO )););)=)=QGGGJJ''J ,,J%j11J r linecxd|jrdnd|j|j}|jJ|jrt }nt}i}|D]7}||jj vr'|jj |r|jj |||<8d|jd|j}t|j|j||j||S)Nz{} {} (line {})z-cz-rline  of r&) formatr*r6r7r'r(#SUPPORTED_OPTIONS_EDITABLE_REQ_DESTSUPPORTED_OPTIONS_REQ_DESTr9__dict__r%)r]r+line_comes_fromsupported_dest req_optionsrr,s rhandle_requirement_linerhs (..)T  O   ' ' ' 4<3K99 49% % %$)*%s line %s has --hash but no requirement, and will be ignored.c3.K|]}|jv |VdSr=)features_enabled)rfr+s r z%handle_option_line..s9,,AW=U4U4U4U4U4U4U,,r Tr) find_links index_urlsno_indexr_r`)source)hashesloggerwarningrequire_hashesrmextendrprq search_scoperr index_urlextra_index_urlsospathdirnameabspathjoinexistsappendupdate_index_urlsrpreset_allow_all_prereleases prefer_binaryset_prefer_binary trusted_hostsadd_trusted_host)r9r6r7rDr+rCrprqrrvaluereq_dirrelative_to_reqs_fileryhostrss ` rhandle_option_liners {  L        9%)%8G "     $ + +,,,,0,,,    *>& & &/ =D HJ > *( *.)J   5 5   d3 4 4 4 ? %OA&Egoobgooh&?&?@@G$&GLL%$@$@ !w~~344 .-   e $ $ $  2  % %j 1 1 1"!!   + 8 /  , , . . .   '  $ $ & & &  >*0b > >777X77((f(====U*>*>N > > > >r ParsedRequirement | Nonec~|jt||}|St|j|j|j|||dS)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)r'rhrr9r6r7)r]r+rDrCrPs rrLrL sS: #,T7;;  I M K       tr c.eZdZddZdd ZddZddZdS)rJrCrrM LineParserr;rjc"||_||_dSr=)_session _line_parser)r@rCrMs r__init__zRequirementsFileParser.__init__Ms   'r r6rr*r-!Generator[ParsedLine, None, None]c#K|||tj|digEd{VdS)z*Parse a given file, yielding parsed lines.N)_parse_and_recurser|r}r)r@r6r*s rrKzRequirementsFileParser.parseUse** jBGOOH$=$=t#D"E           r parsed_files_stacklist[dict[str, str | None]]c#.K|||D]z}|jk|jjs |jjrR|jjr|jjd}d}n|jjd}d}t |r!tj ||}ntt |sZtj tj tj ||}|d}||vr'||}|d|nd} t|d|| |} || |<|||| g|Ed{Vv|V|dS)NrFTz and again in z" recursively references itself in ) _parse_filer'r9 requirements constraints SCHEME_REsearchurllibrKurljoinr|r}rrr~rcopyr) r@r6r*rr]req_pathnested_constraint parsed_files initial_filetailnew_parsed_filess rrz)RequirementsFileParser._parse_and_recurse]s $$Xz::, , D' &(*.)*?(9)-#y5a8H(-%%#y4Q7H(,%##H-- %|33HhGGHH"))(33 "w GOOH55$  H 2!4 |++#/#9L(38777 5#WWxWQUWW$0#4#4#6#6 -5 *22/2B1XEW1X Y, , r c#"Kt||j\}}t|}|D]b\}} ||\}} n.#t$r!} d|d| j} t | d} ~ wwxYwt|||| |VcdS)NzInvalid requirement:  )get_file_contentrr\rOptionParsingErrormsgrr5) r@r6r*_rQr[ line_numberr]args_strr9ers rrz"RequirementsFileParser._parse_files&h >> 7(( !+   K 6!%!2!24!8!8$$% 6 6 6=d==ae==0555 6        sA  A6A11A6N)rCrrMrr;rj)r6rr*r-r;r)r6rr*r-rrr;r)r/r0r1rrKrrrr rrJrJLse((((    2222hr rJrcdfd }|S)Nr]rr;tuple[str, Values]cFt}|}d|_ r j|_t |\}} t j|}n%#t$r}td||d}~wwxYw| ||\}}||fS)NzCould not split options: ) build_parserget_default_valuesrzformat_controlbreak_args_optionsshlexsplit ValueErrorr parse_args) r]rNdefaultsr options_strr+rr9rrDs r parse_linez#get_line_parser..parse_lines,,..!  <&,&;H # 24 8 8+ Wk+..GG W W W$%N%N%NOOUV V W##GX66a~s A!! B+A>>B)r]rr;rr)rDrs` rrIrIs)( r tuple[str, str]c$|d}g}|dd}|D]C}|drn+|||dDd|d|fS)zBreak 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 startswithrpopr)r]tokensr8r+tokens rrrs ZZ__F DQQQiG   K ( (  E KK    KKNNNN 88D>>388G,, ,,r ceZdZddZdS)rrrr;rjc||_dSr=)rr@rs rrzOptionParsingError.__init__s r N)rrr;rj)r/r0r1rrr rrrs(r roptparse.OptionParserctjd}ttz}|D]!}|}||"d d }||_|S) z7 Return a parser for parsing requirement lines F)add_help_optionr@r rrr;r c t|r=)rrs r parser_exitz!build_parser..parser_exits %%%r )r@r rrr;r )optparse OptionParserrr add_optionexit)rNoption_factoriesoption_factoryoptionrs rrrsx "5 9 9 9F(+@@*""!!&!!!!&&&& FK Mr r[c#Kd}g}|D]\}}|drt|r]t|rd|z}|r5|||J|d|fVg}||fV|s|}||d|r|J|d|fVdSdS)zJoins a line ending in '' with the previous line (except when following comments). The joined line takes on the index of the first line. N\rr)endswith COMMENT_REmatchrrstrip)r[primary_line_numbernew_linerr]s rrXrXs?H'.. T}}T"" .j&6&6t&<&< .%% "Tz (%%%*666)2778+<+<<<<<!4''''' 2&1# OODJJt,, - - - -5"...!2778#4#444444455r c#K|D]<\}}td|}|}|r||fV=dS)z1 Strips comments and filter empty lines. rN)rsubr)r[rr]s rrYrY s`($$ T~~b$''zz||  $t# # # # $$r c#K|D]X\}}t|D]2\}}tj|}|s|||}3||fVYdS)aReplace 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 `_. Valid characters in variable names follow the `POSIX standard `_ and are limited to uppercase letter, digits and the `_` (underscore). N) ENV_VAR_REfindallr|getenvreplace)r[rr]env_varvar_namers rrZrZs (   T!+!3!3D!9!9 0 0 GXIh''E <<//DD4  r urlctj|j}|dvr4ddlm}||}|||j|jfS t|d5}| }dddn #1swxYwYn$#t$r}td|d}~wwxYwt||}||fS)aGets 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. )httphttpsfiler)raise_for_statusrbNz"Could not open requirements file: )rrKurlsplitschemepip._internal.network.utilsrgetrtextopenreadOSErrorr _decode_req_file) rrCrrresprn raw_contentexcrQs rrr3s4\ " "3 ' ' .F ***@@@@@@{{3x""L #t__ #&&((K # # # # # # # # # # # # # # # LLL JS J JKKKL{C00G <s<B.B BBBBB B<%B77B<databytesctD]F\}}||r,|t|d|cSG|dddD]p}|dddkr`t |}|D|dd}||cSq |tS#t$r\tj dptj }tjd|t||||cYSwxYw) N rrT#asciiFzunable to decode data from %s with default encoding %s, falling back to encoding from locale: %s. If this is intentional you should specify the encoding with a PEP-263 style comment, e.g. '# -*- coding: %s -*-')r"rlendecoderPEP263_ENCODING_RErgroupsDEFAULT_ENCODINGUnicodeDecodeErrorlocalegetpreferredencodingsysgetdefaultencodingloggingrv)rrbomencodingr]resultlocale_encodings rrrQsu55 X ??3   5C #**844 4 4 4 5 5!!"1"%-- !9  '..t44F!!==??1-44W=={{8,,,,,,{{+,,,  , , , 5e<<X@V@X@X A     {{?+++++ ,sC88A#EE)NNF) r6rrCrrDrEr+rFr*r-r;rG)rQrr;rRr=)r]r5r+rFr;r%)NNN)r9rr6rr7r:rDrEr+rFrCrir;rj) r]r5r+rFrDrErCrir;r)rDrEr;r)r]rr;r)r;r)r[rRr;rR)rrrCrr;r)rrrrr;r)c__doc__ __future__rcodecsr rrr|rerr  urllib.parsercollections.abcrr dataclassesrrtypingrr r r pip._internal.clir pip._internal.exceptionsr r!pip._internal.models.search_scoper"pip._internal.index.package_finderrpip._internal.network.sessionr__all__tupler:rrRrcompileIrrrrzextra_index_urlrrrreditablerp no_binary only_binaryrrwr trusted_hostuse_new_featurerr3hashconfig_settingsrrrcrbBOM_UTF8 BOM_UTF32 BOM_UTF32_BE BOM_UTF32_LE BOM_UTF16 BOM_UTF16_BE BOM_UTF16_LEr"rr  getLoggerr/rur%r5rr\rhrrLrJrIr ExceptionrrrXrYrZrrrr rr6s#"""""  ////////!!!!!!)(((((RRRRRRRR9999999@@@@@@888888  c3h( seU3;// 0 BJ-rt 4 4 RZ ' ' RZ> ? ? N;&O? H LK5JKKK''9'''# _g x  +& +& x  +& +&! RZ :;;  8 $ $ $& $4$(&* 6    '+L$(&*!% C>C>C>C>C>P'+#'!% )))))XZZZZZZZZz0----" .5555>$$$$    6<,,,,,,r