B ReK@sVdZddlmZddlZddlZddlZddlZddlZddlm Z ddl m Z ddl mZmZddlmZddlmZdd lmZdd lmZdd lmZerdd 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.dZ1e.dZ2e j3e j4e j5e j6e j7e j8e j9e j:e j;e je j?e j@gZAe jBe jCe jDgZEddeEDZFGdddeGZHGdddeGZId7ddZJddZKd8ddZLd9d d!ZMd:d"d#ZNGd$d%d%eGZOd&d'ZPd(d)ZQGd*d+d+eRZSd,d-ZTd.d/ZUd0d1ZVd2d3ZWd;d4d5ZXe.d6ej/ZYdS)\$\{(?P[A-Z0-9_]+)\})cCsg|]}t|jqS)strdest).0orr/builddir/build/BUILDROOT/alt-python37-pip-20.2.4-6.el8.x86_64/opt/alt/python37/lib/python3.7/site-packages/pip/_internal/req/req_file.py Lsrc@seZdZdddZdS)ParsedRequirementNcCs(||_||_||_||_||_||_dS)N) requirement is_editable comes_fromoptions constraint line_source)selfr!r"r#r%r$r&rrr__init__Ps zParsedRequirement.__init__)NN)__name__ __module__ __qualname__r(rrrrr Osr c@seZdZddZdS) ParsedLinecCs`||_||_||_||_||_|r6d|_d|_||_n&|jrVd|_d|_|jd|_nd|_dS)NTFr) filenamelinenor#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|||D]"}t||||d} | dk r"| Vq"WdS)aParse 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$findersessionN)get_line_parserRequirementsFileParserr handle_line) r-r4r3r#r$r% line_parserparser parsed_line parsed_reqrrrrs 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_linesignore_commentsexpand_env_variables)content lines_enumrrr preprocesss rEcCsd|jrdnd|j|j}|js&t|jrBt|j|j||jdS|rTt ||j i}x4t D],}||j j kr^|j j |r^|j j |||<q^Wd|j|j}t|j|j||j||dSdS)Nz{} {} (line {})z-cz-r)r!r"r#r%z line {} of {})r!r"r#r%r$r&)formatr%r-r.r0AssertionErrorr"r r!rcheck_install_build_globalr/SUPPORTED_OPTIONS_REQ_DEST__dict__)liner$line_comes_from req_optionsrr&rrrhandle_requirement_lines.   rNcs(r4|jr|j_|jr4jfdd|jD|r$|j}|j}|jrT|jg}|jdkrbg}|jrt||j|jr|jd}tj tj |} tj | |} tj | r| }||t||d} | |_|jr||jr||r$x.|jpgD] } d||} |j| | dqWdS)Nc3s|]}|jkr|VqdS)N)features_enabled)rf)r$rr sz%handle_option_line..Tr) find_links index_urlsz line {} of {})source)require_hashesrOextendrRrS index_urlno_indexextra_index_urlsospathdirnameabspathjoinexistsappendr search_scopepreset_allow_all_prereleases prefer_binaryset_prefer_binary trusted_hostsrFadd_trusted_host)r/r-r.r3r$r4rRrSvaluereq_dirrelative_to_reqs_filerahostrTr)r$rhandle_option_linesD       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,eZdZddZddZddZddZd S) r6cCs||_||_||_dS)N)_session _line_parser _comes_from)r'r4r8r#rrrr(CszRequirementsFileParser.__init__ccs x|||D] }|VqWdS)z3Parse a given file, yielding parsed lines. N)_parse_and_recurse)r'r-r%rKrrrrNszRequirementsFileParser.parseccsx|||D]}|js|jjs(|jjr|jjrB|jjd}d}n|jjd}d}t|rjt||}n t|st j t j ||}x"| ||D] }|VqWq|VqWdS)NrFT) _parse_filer0r/ requirements constraints SCHEME_REsearch urllib_parseurljoinrZr[r^r\rp)r'r-r%rKreq_pathnested_constraint inner_linerrrrpUs"      z)RequirementsFileParser._parse_and_recursec cst||j|jd\}}t|}xr|D]j\}}y||\}} Wn8tk rv} zd|| j} t| Wdd} ~ XYnXt |||j|| |Vq$WdS)N)r#zInvalid requirement: {} {}) get_file_contentrmrorErnOptionParsingErrorrFmsgrr,) r'r-r%_rCrD line_numberrKargs_strr/er}rrrrqvs z"RequirementsFileParser._parse_fileN)r)r*r+r(rrprqrrrrr6Bs !r6csfdd}|S)Ncs^t}|}d|_r j|_t|\}}tjdkr@|d}|t ||\}}||fS)N)utf8) build_parserget_default_valuesrWformat_controlbreak_args_optionssys version_infoencode parse_argsshlexsplit)rKr9defaultsr options_strr/r~)r3rr parse_lines   z#get_line_parser..parse_liner)r3rr)r3rr5s r5cCsh|d}g}|dd}x8|D]0}|ds8|dr.parser_exit)optparse OptionParserSUPPORTED_OPTIONSSUPPORTED_OPTIONS_REQ add_optionexit)r9option_factoriesoption_factoryoptionrrrrrs  rccsd}g}x|D]\}}|dr*t|rxt|r`_. Valid characters in variable names follow the `POSIX standard `_ and are limited to uppercase letter, digits and the `_` (underscore). N) ENV_VAR_REfindallrZgetenvreplace)rDrrKenv_varvar_namerhrrrrBs rBc Cs$t|}|dkr.||}t||j|jfS|dkr|rT|drTtd|||ddd}| dd}t |}|r| dd|d dd}t |}|drd|d}|}y&t|d }t|}Wd QRXWn2tk r} ztd | Wd d } ~ 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. )httphttpsfilerz6Requirements file {} references URL {}, which is local:r<r/|rbNz$Could not open requirements file: {})r getrurltextrrrFrr_url_slash_drive_rergrouprvunquotelstripopenr readIOError) rr4r#schemerespr[rrPrCexcrrrr{#s4         r{z /*([a-z])\|)NNNF)N)NNN)NNN)N)Z__doc__ __future__rrrZrerrZpip._vendor.six.moves.urllibrrvZpip._internal.clirpip._internal.exceptionsrr!pip._internal.models.search_scoperpip._internal.network.utilsrpip._internal.utils.encodingr pip._internal.utils.typingr pip._internal.utils.urlsr r typingr rrrrrrrr"pip._internal.index.package_finderrpip._internal.network.sessionrintZ ReqFileLinesrZ LineParser__all__compileIrtrrrWextra_index_urlrXrsrreditablerR no_binary only_binaryrdrUrb trusted_hostuse_new_featurerinstall_optionsglobal_optionshashrrIobjectr r,rrErNrlr7r6r5r Exceptionr|rr@rArBr{rrrrrs         ,    !  . 7 )N   -