Re D@UdZddlZddlZddlZddlZddlZddlmZddlm Z m Z m Z m Z m Z mZmZmZmZddlmZddlmZmZddlmZddlmZdd lmZdd lmZdd lm Z e r dd lm!Z!dd l"m#Z#dgZ$e ee%e&fZ'e e&gee&effZ(ej)dej*Z+ej)dZ,ej)dZ-ej.ej/ej0ej1ej2ej3ej4ej5ej6ej7ej8ej9ej:ej;gZd<ej?ej@ejAgZBee dej=fe>d<deBDZCGddZDGddZE d8de&dededdeejd eFd!eeDf d"ZGd#e&d!e'fd$ZH d9d%eEdeejd!eDfd&ZI d:d'ede&d(e%deddeejdeed!dfd)ZJ d:d%eEdeejdeddeed!eeDf d*ZKGd+d,ZLdedd!e(fd-ZMd%e&d!ee&e&ffd.ZNGd/d0eOZPd!ejQfd1ZRd2e'd!e'fd3ZSd2e'd!e'fd4ZTd2e'd!e'fd5ZUd6e&ded!ee&e&ffd7ZVdS);z Requirements file parsing N)Values) TYPE_CHECKINGAnyCallableDictIterableIteratorListOptionalTuple) cmdoptions)InstallationErrorRequirementsFileParseError) SearchScope) PipSession)raise_for_status) auto_decode)get_url_scheme)NoReturn) PackageFinderparse_requirementsz^(http|https|file):z (^|\s+)#.*$z#(?P\$\{(?P[A-Z0-9_]+)\}).SUPPORTED_OPTIONSSUPPORTED_OPTIONS_REQcFg|]}t|jS)strdest).0os /builddir/build/BUILDROOT/alt-python311-pip-21.3.1-3.el8.x86_64/opt/alt/python311/lib/python3.11/site-packages/pip/_internal/req/req_file.py r!Ns&KKKc!!##(mmKKKc`eZdZ d dededededeeeefdeeddfd ZdS) ParsedRequirementN requirement is_editable comes_from constraintoptions line_sourcereturncZ||_||_||_||_||_||_dSN)r%r&r'r)r(r*)selfr%r&r'r(r)r*s r __init__zParsedRequirement.__init__Rs7'&$ $&r")NN) __name__ __module__ __qualname__rboolr rrr/rr"r r$r$Qs-1%)'''' '  ' $sCx.) 'c]' ''''''r"r$c .eZdZdedededededdf dZdS) ParsedLinefilenamelinenoargsoptsr(r+Nc||_||_||_||_|rd|_d|_||_dS|jr"d|_d|_|jd|_dSd|_dS)NTFr)r6r7r9r(is_requirementr&r% editables)r.r6r7r8r9r(s r r/zParsedLine.__init__ds!   $  ("&D $D #D    ^ ("&D #D #~a0D   "'D   r")r0r1r2rintrr3r/rr"r r5r5csb((( (  (  ( ((((((r"r5Fr6sessionfinderrr)r(r+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)r?r>N)get_line_parserRequirementsFileParserparse handle_line) r6r>r?r)r( line_parserparser parsed_line parsed_reqs r rr~s} "&))K #G[ 9 9F||Hj99       !    r"contentct|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)rI lines_enums r preprocessrSsO )););)=)=QGGGJJ''J ,,J%j11J r"linecd|jrdnd|j|j}|jsJ|jr"t |j|j||jS|rtj ||j i}tD]7}||j j vr'|j j |r|j j |||<8d|jd|j}t |j|j||j||S)Nz{} {} (line {})z-cz-r)r%r&r'r(line  of )r%r&r'r(r)r*) formatr(r6r7r;r&r$r%r check_install_build_globalr9SUPPORTED_OPTIONS_REQ_DEST__dict__)rTr)line_comes_from req_optionsrr*s r handle_requirement_liner^s. (..)T  O    !((&       F  1'49 E E E . = =Dty)))di.@.F)$(I$6t$< D!>dk>>t}>>  ((&#     r"r9r7crE|jr |j_|jr+jfd|jD|r|j}|j}|jr|jg}|jdurg}|jr||j|jr|jd}tj tj |} tj | |} tj | r| }|||r||t!||} | |_|jr||jr||r-|jpgD]%} d|d|} || | "dSdSdS)Nc3.K|]}|jv |VdSr-)features_enabled)rfr)s r z%handle_option_line..s9,,AW=U4U4U4U4U4U4U,,r"Tr) find_links index_urlsrVrW)source)require_hashesraextendrdre index_urlno_indexextra_index_urlsospathdirnameabspathjoinexistsappendupdate_index_urlsr search_scopepreset_allow_all_prereleases prefer_binaryset_prefer_binary trusted_hostsadd_trusted_host)r9r6r7r?r)r>rdrevaluereq_dirrelative_to_reqs_filerthostrfs ` r handle_option_liners<   9%)%8G "     $ + +,,,,0,,,    '>& & > *.)J =D J   5   d3 4 4 4 ? %OA&Egoobgooh&?&?@@G$&GLL%$@$@ !w~~344 .-   e $ $ $  2  % %j 1 1 1"!!   + 8 /  , , . . .   '  $ $ & & &  >*0b > >777X77((f(====O'>'>H > > > >r"c~|jrt||}|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;r^rr9r6r7)rTr)r?r>rHs r rDrDsU:  ,T7;;  I M K       tr"ceZdZdededdfdZdededee fdZ dededee fd Z dededee fd Z dS) rBr>rEr+Nc"||_||_dSr-)_session _line_parser)r.r>rEs r r/zRequirementsFileParser.__init__<s   'r"r6r(c#BK|||Ed{VdS)z*Parse a given file, yielding parsed lines.N)_parse_and_recurse)r.r6r(s r rCzRequirementsFileParser.parseDs4**8Z@@@@@@@@@@@r"c#PK|||D] }|js|jjs |jjr|jjr|jjd}d}n|jjd}d}t |r!tj ||}nWt |s=tj tj ||}|||Ed{V|V dS)NrFT) _parse_filer;r9 requirements constraints SCHEME_REsearchurllibrCurljoinrlrmrprnr)r.r6r(rTreq_pathnested_constraints r rz)RequirementsFileParser._parse_and_recurseHs;$$Xz::  D&  & *.)*? 9)-#y5a8H(-%%#y4Q7H(,%##H-- %|33HhGGHH"))(33!w||11   H  228=NOOOOOOOOOO 5  r"c#"Kt||j\}}t|}|D]b\}} ||\}} n.#t$r!} d|d| j} t | d} ~ wwxYwt|||| |VcdS)NzInvalid requirement:  )get_file_contentrrSrOptionParsingErrormsgrr5) r.r6r(_rIrR line_numberrTargs_strr9ers r rz"RequirementsFileParser._parse_filegs%h >> 7(( !+   K 6!%!2!24!8!8$$% 6 6 6=d==ae==0555 6        sA  A6A11A6) r0r1r2r LineParserr/rr3r r5rCrrrr"r rBrB;s(( (  ((((AcAtA8LAAAA)- * >CThz>Rr"rBcTdtdtttfffd }|S)NrTr+ct}|}d|_r j|_t |\}}|t j||\}}||fSr-) build_parserget_default_valuesriformat_controlbreak_args_options parse_argsshlexsplit)rTrFdefaultsr options_strr9rr?s r parse_linez#get_line_parser..parse_line~sy,,..!  <&,&;H # 24 8 8+##EK $<$>388G,, ,,r"ceZdZdeddfdZdS)rrr+Nc||_dSr-)rr.rs r r/zOptionParsingError.__init__s r")r0r1r2rr/rr"r rrs6CDr"rctjd}ttz}|D]!}|}||"dt dt ddfd}||_|S)z7 Return a parser for parsing requirement lines F)add_help_optionr.rr+rc t|r-)rrs r parser_exitz!build_parser..parser_exits %%%r")optparse OptionParserrr add_optionrrexit)rFoption_factoriesoption_factoryoptionrs r rrs "5 9 9 9F(+@@*""!!&!!!!&#&C&J&&&& FK Mr"rRc#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\r)endswith COMMENT_REmatchrrrpstrip)rRprimary_line_numbernew_linerrTs r rOrOs?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)rRrrTs r rPrPs`($$ 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_REfindallrlgetenvreplace)rRrrTenv_varvar_namer{s r rQrQs (   T!+!3!3D!9!9 0 0 GXIh''E <<//DD4  r"urlcrt|}|dvr2||}t||j|jfS t |d5}t |}dddn #1swxYwYn$#t$r}td|d}~wwxYw||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. )httphttpsfilerbNz"Could not open requirements file: ) rgetrrtextopenrreadOSErrorr)rr>schemeresprbrIexcs r rrs C F***{{3x""L #t__ ,!!&&((++G , , , , , , , , , , , , , , , LLL JS J JKKKL <s<B"B9 BB  B B  B B2B--B2)NNFr-)NNN)W__doc__rrlrer urllib.parserrtypingrrrrrr r r r pip._internal.clir pip._internal.exceptionsrr!pip._internal.models.search_scoperpip._internal.network.sessionrpip._internal.network.utilsrpip._internal.utils.encodingrpip._internal.utils.urlsrr"pip._internal.index.package_finderr__all__r=r ReqFileLinesrcompileIrrrriextra_index_urlrjrreditablerd no_binary only_binaryrwrgru trusted_hostuse_new_featurerOption__annotations__install_optionsglobal_optionshashrrZr$r5r3rrSr^rrDrBrAr ExceptionrrrrOrPrQrrr"r rs#                       )(((((RRRRRRRR999999444444888888444444333333A @@@@@@  c3h( seU3;// 0 BJ-rt 4 4 RZ ' ' RZ> ? ? N;4ho!567&O?tHS(/%9:;LK5JKKK''''''''$((((((((<)-)-   _ %ho &     6      *.* * * ho &* * * * * b)-)-$( :>:> :>:> :> _ % :> ho & :> j ! :> :>:>:>:>~*.(,$( )) ) ho &) _ %)j ! )  ))))X????????DH_5*&-S-U38_----" h+.5<5L5555>$ $$$$$ \ l    6# uS#Xr"