\h~EUdZddlZddlZddlZddlZddlZddlZddlmZddl m Z m Z m Z m Z mZmZmZmZmZddlmZddlmZmZddlmZddlmZdd lmZdd lmZdd l m!Z!e r dd l m"Z"dd l#m$Z$dgZ%eee&e'fZ(e e'gee'effZ)ejTdejVZ,ejTdZ-ejTdZ.ej^ej`ejbejdejfejhejjejlejnejpejrejtejvejxgZ=ee dej|fe?d<ejejejgZCee dej|fe?d<ejgZDee dej|fe?d<eCDcgc]}e'|jc}ZFeDDcgc]}e'|jc}ZGejeIZJGddZKGddZL d7de'dededdeejdeMd eeKddff d!ZNd"e'd e(fd#ZO d8d$eLdeejd eKfd%ZP d9d&ede'd'e&deddeejdeed dfd(ZQ d9d$eLdeejdeddeed eeKf d)ZRGd*d+ZSdedd e)fd,ZTd$e'd ee'e'ffd-ZUGd.d/eVZWd ejfd0ZYd1e(d e(fd2ZZd1e(d e(fd3Z[d1e(d e(fd4Z\d5e'ded ee'e'ffd6Z]ycc}wcc}w):z Requirements file parsing N)Values) TYPE_CHECKINGAnyCallableDict GeneratorIterableListOptionalTuple) 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_REQSUPPORTED_OPTIONS_EDITABLE_REQcLeZdZ d dededededeeeefdeeddfd Zy) ParsedRequirementN requirement is_editable comes_from constraintoptions line_sourcereturncX||_||_||_||_||_||_yN)rrrr!r r")selfrrrr r!r"s ]/root/niggaflix-v3/playground/venv/lib/python3.12/site-packages/pip/_internal/req/req_file.py__init__zParsedRequirement.__init__]s1'&$ $&)NN) __name__ __module__ __qualname__strboolr rrr(r)r'rr\sd-1%)''' '  ' $sCx.) 'c]' 'r)rc ,eZdZdedededededdf dZy) ParsedLinefilenamelinenoargsoptsr r#Nc||_||_||_||_|rd|_d|_||_y|jr#d|_d|_|jd|_yd|_y)NTFr)r2r3r5r is_requirementrr editables)r&r2r3r4r5r s r'r(zParsedLine.__init__osk!   $ "&D $D #D  ^^"&D #D #~~a0D "'D r))r*r+r,r-intrr.r(r/r)r'r1r1nsA((( (  (  ( (r)r1r2sessionfinderrr!r r#c#Kt|}t||}|j||D]}t||||}||yw)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) r2r:r;r!r line_parserparser parsed_line parsed_reqs r'rrsY "&)K #G[ 9F||Hj9     !  s >AAcontentc~t|jd}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)rE lines_enums r' preprocessrOs= )););)=QGJJ'J ,J%j1J r)linecdj|jrdnd|j|j}|jsJ|j rt }nt}i}|D]Q}||jjvs|jj|s6|jj|||<Sd|jd|j}t|j|j ||j||S)Nz{} {} (line {})z-cz-rline  of )rrrr r!r") formatr r2r3r7r#SUPPORTED_OPTIONS_EDITABLE_REQ_DESTSUPPORTED_OPTIONS_REQ_DESTr5__dict__rr)rPr!line_comes_fromsupported_dest req_optionsdestr"s r'handle_requirement_liner\s (..T  O     <3K9 499%% %$))*<*%s line %s has --hash but no requirement, and will be ignored.c3@K|]}|jvs|ywr%)features_enabled).0fr!s r' z%handle_option_line..s#,AW=U=U4U,sTr) find_links index_urlsno_indexrRrS)source)hashesloggerwarningrequire_hashesr_extendrcrd search_scopere index_urlextra_index_urlsospathdirnameabspathjoinexistsappendupdate_index_urlsrpreset_allow_all_prereleases prefer_binaryset_prefer_binary trusted_hostsadd_trusted_host)r5r2r3r;r!r:rcrdrevaluereq_dirrelative_to_reqs_filerlhostrfs ` r'handle_option_liners {{ L      %)%8%8G "   $ $ + +,00,  && && &&// ==D HJ >>(..)J     d33 4 ??OOA&Eggoobggooh&?@G$&GGLL%$@ !ww~~34-   e $   % %j 1"!! + 88  , , .     $ $ & **0b > XJ7((f(= > Or)c|jrt||}|St|j|j|j |||y)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)r7r\rr5r2r3)rPr!r;r:rDs r'r@r@sJ: ,T7;  II MM KK     r)c eZdZdededdfdZdededee ddffdZ dededee ddffd Z dededee ddffd Z y) r>r:rAr#Nc ||_||_yr%)_session _line_parser)r&r:rAs r'r(zRequirementsFileParser.__init__Es   'r)r2r c#DK|j||Ed{y7w)z*Parse a given file, yielding parsed lines.N)_parse_and_recurse)r&r2r s r'r?zRequirementsFileParser.parseMs**8Z@@@s   c#K|j||D]1}|js|jjs|jjr|jjr|jjd}d}n|jjd}d}t j |r!tjj||}nRt j |s=tjjtjj||}|j||Ed{.|4y7w)NrFT) _parse_filer7r5 requirements constraints SCHEME_REsearchurllibr?urljoinrorprsrqr)r&r2r rPreq_pathnested_constraints r'rz)RequirementsFileParser._parse_and_recurseSs$$Xz: D&& &&$))*?*?99))#yy55a8H(-%#yy44Q7H(,%##H-%||33HhGH"))(3!ww||1  H  228=NOOO 5 0PsD:E <E =E c#Kt||j\}}t|}|D]+\}} |j|\}} t|||| |-y#t$r"} d|d| j } t | d} ~ wwxYww)NzInvalid requirement:  )get_file_contentrrOrOptionParsingErrormsgrr1) r&r2r _rErN line_numberrPargs_strr5ers r'rz"RequirementsFileParser._parse_filers&h > 7( !+  K 6!%!2!24!8$    & 6-dV2aeeW=055 6s(-BAB B!A>>BB) r*r+r,r LineParserr(r-r.rr1r?rrr/r)r'r>r>Ds(( (  (AA)-A :tT) *A )- :tT) *>)- :tT) *r)r>cFdtdtttfffd }|S)NrPr#c&t}|j}d|_ r j|_t |\}} t j |}|j||\}}||fS#t$r}td||d}~wwxYw)NzCould not split options: ) build_parserget_default_valuesrmformat_controlbreak_args_optionsshlexsplit ValueErrorr parse_args) rPrBdefaultsr options_strr!rr5rr;s r' parse_linez#get_line_parser..parse_lines,,.! &,&;&;H # 24 8+ Wkk+.G##GX6a~  W$'@ %NOUV V WsA33 B<B  B)r-r r)r;rs` r'r=r=s'sF{!3( r)c|jd}g}|dd}|D]H}|jds|jdrn$|j||jdJdj |dj |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 startswithrupoprs)rPtokensr4r!tokens r'rrs ZZ_F DQiG   C E$4$4T$:  KK  KKN  88D>388G, ,,r)ceZdZdeddfdZy)rrr#Nc||_yr%)rr&rs r'r(zOptionParsingError.__init__s r))r*r+r,r-r(r/r)r'rrsCDr)rctjd}ttz}|D]}|}|j |dt dt ddfd}||_|S)z7 Return a parser for parsing requirement lines F)add_help_optionr&rr#rct|r%)rrs r' parser_exitz!build_parser..parser_exits  %%r))optparse OptionParserrr add_optionrr-exit)rBoption_factoriesoption_factoryoptionrs r'rrsm " "5 9F(+@@*"!&!" &#&C&J& FK Mr)rNc#Kd}g}|D]\}}|jdrtj|rPtj|rd|z}|r-|j||J|dj |fg}u||f||s|}|j|j d|r|J|dj |fyyw)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_REmatchrursstrip)rNprimary_line_numbernew_linerrPs r'rKrKsH'. T}}T"j&6&6t&<%Tz%*666)2778+<<<!4''&1# OODJJt, -.$"...!2778#444sCCc#~K|D]4\}}tjd|}|j}|s/||f6yw)z1 Strips comments and filter empty lines. rN)rsubr)rNrrPs r'rLrLsE($ T~~b$'zz| t# # $s1= =c#K|D]R\}}tj|D]/\}}tj|}|s|j ||}1||fTyw)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_REfindallrogetenvreplace)rNrrPenv_varvar_namer}s r'rMrMsl (  T!+!3!3D!9 0 GXIIh'E<</D  04 sAAurlcDt|}|dvr4|j|}t||j|jfS t |d5}t |j}ddd|fS#1swY xYw#t$r}td|d}~wwxYw)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:schemeresprarEexcs r'rrsC F**{{3xx""L #t_ ,!!&&(+G , <  , , L"DSE JKKLs0 BA7+B7B<B B BB)NNFr%)NNN)^__doc__loggingrrorer 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__r9r- ReqFileLinesrcompileIrrrrmextra_index_urlrerreditablerc no_binary only_binaryryrjrw trusted_hostuse_new_featurerOption__annotations__global_optionshashconfig_settingsrrr[rVrU getLoggerr*rhrr1r.rrOr\rr@r>r=r ExceptionrrrrKrLrMr)os0r'rs`    )R94843 @  c3h( seU3;// 0 BJJ-rtt 4 RZZ ' RZZ> ? NN;4hoo!567&OO?tHS(//%9:;HXc8??.B%C D 6KKc!#((mK9'CM'#   8 $''$((<)-)-   _ %hoo &     $,- 6   *.  hoo &L)-)-$( C> C>C> C> _ % C> hoo & C> j ! C> C>P*.(,$( ) ) hoo &) _ %)j ! )  )XCCLH_5*0-S-U38_-" h++.5<5L5>$ $$ \ l 6# uS#XAL's "MM