3 ”Reø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-ej.dej/ƒZ0ej.dƒZ1ej.dƒZ2e j3e j4e j5e j6e j7e j8e j9e j:e j;e je 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„ZXej.d6ej/ƒZYdS)\$\{(?P[A-Z0-9_]+)\})cCsg|]}t|ƒjƒ‘qS©)ÚstrÚdest)Ú.0Úorrú‰/builddir/build/BUILDROOT/alt-python36-pip-20.2.4-5.el8.x86_64/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/req/req_file.pyú 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 Osr c@seZdZdd„ZdS)Ú ParsedLinecCs`||_||_||_||_||_|r6d|_d|_||_n&|jrVd|_d|_|jd|_nd|_dS)NTFr) ÚfilenameÚlinenor#Úoptsr%Úis_requirementr"r!Ú editables)r'r-r.r#Úargsr/r%rrrr(cs zParsedLine.__init__N)r)r*r+r(rrrrr,bsr,Fc csLt|ƒ}t|||ƒ}x2|j||ƒD]"}t||||d�} | dk r"| Vq"WdS)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-r4r3r#r$r%Ú line_parserÚparserÚ parsed_lineÚ parsed_reqrrrr€s cCs,t|jƒ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 rEcCs¼dj|jrdnd|j|jƒ}|js&t‚|jrBt|j|j||jd�S|rTt j ||j ƒi}x4t D],}||j j kr^|j j |r^|j j |||<q^Wdj|j|jƒ}t|j|j||j||d�SdS)Nz{} {} (line {})z-cz-r)r!r"r#r%z line {} of {})r!r"r#r%r$r&)Úformatr%r-r.r0ÚAssertionErrorr"r r!rÚcheck_install_build_globalr/ÚSUPPORTED_OPTIONS_REQ_DESTÚ__dict__)Úliner$Úline_comes_fromÚ req_optionsrr&rrrÚhandle_requirement_line®s.   rNcs(ˆr4|jr|jˆ_|jr4ˆjj‡fdd„|jDƒƒ|�r$|j}|j}|jrT|jg}|jdkrbg}|jrt|j|jƒ|jrÀ|jd}tj j tj j |ƒƒ} tj j | |ƒ} tj j | ƒr¶| }|j|ƒt||d�} | |_|jrà|jƒ|jrî|jƒ|�r$x.|jpþgD] } dj||ƒ} |j| | d��qWdS)Nc3s|]}|ˆjkr|VqdS)N)Úfeatures_enabled)rÚf)r$rrú êsz%handle_option_line..Tr)Ú find_linksÚ index_urlsz line {} of {})Úsource)Úrequire_hashesrOÚextendrRrSÚ 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_hostsrFÚadd_trusted_host)r/r-r.r3r$r4rRrSÚvalueÚreq_dirÚrelative_to_reqs_fileraÚhostrTr)r$rÚhandle_option_lineÚsD       rlcCs4|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)r0rNrlr/r-r.)rKr$r3r4r;rrrr7s r7c@s,eZdZdd„Zdd„Zdd„Zdd„Zd S) r6cCs||_||_||_dS)N)Ú_sessionÚ _line_parserÚ _comes_from)r'r4r8r#rrrr(CszRequirementsFileParser.__init__ccs x|j||ƒD] }|VqWdS)z3Parse a given file, yielding parsed lines. N)Ú_parse_and_recurse)r'r-r%rKrrrrNszRequirementsFileParser.parseccs¸x²|j||ƒD]¢}|j rª|jjs*|jjrª|jjrD|jjd}d}n|jjd}d}tj|ƒrltj||ƒ}n tj|ƒsŒt j j t j j |ƒ|ƒ}x"|j ||ƒD] }|VqšWq|VqWdS)NrFT)Ú _parse_filer0r/Ú requirementsÚ constraintsÚ SCHEME_REÚsearchÚ urllib_parseÚurljoinrZr[r^r\rp)r'r-r%rKÚreq_pathÚnested_constraintÚ inner_linerrrrpUs"      z)RequirementsFileParser._parse_and_recursec cs–t||j|jd�\}}t|ƒ}xr|D]j\}}y|j|ƒ\}} Wn8tk rv} zdj|| jƒ} t| ƒ‚WYdd} ~ XnXt |||j|| |ƒVq$WdS)N)r#zInvalid requirement: {} {}) Úget_file_contentrmrorErnÚOptionParsingErrorrFÚmsgrr,) r'r-r%Ú_rCrDÚ line_numberrKÚargs_strr/Úer}rrrrqvs z"RequirementsFileParser._parse_fileN)r)r*r+r(rrprqrrrrr6Bs !r6cs‡fdd„}|S)Ncs^tƒ}|jƒ}d|_ˆr ˆj|_t|ƒ\}}tjdkr@|jdƒ}|jt j |ƒ|ƒ\}}||fS)NéééÚutf8)r‚rƒr„) Ú build_parserÚget_default_valuesrWÚformat_controlÚbreak_args_optionsÚsysÚ version_infoÚencodeÚ parse_argsÚshlexÚsplit)rKr9Údefaultsr€Ú options_strr/r~)r3rrÚ parse_line’s   z#get_line_parser..parse_liner)r3r’r)r3rr5�s r5cCsh|jdƒ}g}|dd…}x8|D]0}|jdƒs8|jdƒr.parser_exit)ÚoptparseÚ OptionParserÚSUPPORTED_OPTIONSÚSUPPORTED_OPTIONS_REQÚ add_optionÚexit)r9Úoption_factoriesÚoption_factoryÚoptionršrrrr†Ãs  r†ccsºd}g}xŒ|D]„\}}|jdƒ s,tj|ƒrztj|ƒr>d|}|rn|j|ƒ|dk sXt‚|dj|ƒfVg}q’||fVq|s‚|}|j|jdƒƒqW|r¶|dk s¦t‚|dj|ƒ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Úmatchr`rGr^Ústrip)rDÚprimary_line_numberÚnew_linerrKrrrr@Ûs$     r@ccs8x2|D]*\}}tjd|ƒ}|jƒ}|r||fVqWdS)z1 Strips comments and filter empty lines. r¥N)r§Úsubr©)rDrrKrrrrAûs  rAccsTxN|D]F\}}x2tj|ƒD]$\}}tj|ƒ}|s2q|j||ƒ}qW||fVqWdS)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 `_. Valid characters in variable names follow the `POSIX standard `_ and are limited to uppercase letter, digits and the `_` (underscore). N)Ú ENV_VAR_REÚfindallrZÚgetenvÚreplace)rDrrKÚenv_varÚvar_namerhrrrrBs rBc Cs$t|ƒ}|d kr.|j|ƒ}t|ƒ|j|jfS|dkrÂ|rT|jdƒrTtdj||ƒƒ‚|jddƒd}|j ddƒ}t j |ƒ}|rœ|j dƒd|jd dƒd}t j|ƒ}|jdƒr¾d|jdƒ}|}y&t|d ƒ�}t|jƒƒ}Wd QRXWn2tk �r} ztd j| ƒƒ‚WYd d } ~ XnX||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Úfilez6Requirements file {} references URL {}, which is localú:r<r¤ú/ú|ÚrbNz$Could not open requirements file: {})r³r´)r ÚgetrÚurlÚtextr•rrFr�r°Ú_url_slash_drive_rer¨ÚgrouprvÚunquoteÚlstripÚopenr ÚreadÚIOError) r»r4r#ÚschemeÚrespr[r¨rPrCÚexcrrrr{#s4         r{z /*([a-z])\|)NNNF)N)NNN)NNN)N)ZÚ__doc__Ú __future__rr›rZÚrerŽrŠZpip._vendor.six.moves.urllibrrvZpip._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ÚIrtr§r­rWÚextra_index_urlrXrsrrÚeditablerRÚ no_binaryÚ only_binaryrdrUrbÚ trusted_hostÚuse_new_featurer�Úinstall_optionsÚglobal_optionsÚhashržrIÚobjectr r,rrErNrlr7r6r5r‰Ú Exceptionr|r†r@rArBr{r½rrrrÚs†         ,    !  . 7 )N   -