U n aJ @sFdZddlmZddlZddlZddlZddlZddlZddlm Z ddl m Z ddl mZmZddlmZddlmZdd lmZdd lmZer dd lmZdd lmZmZmZmZmZmZm Z m!Z!m"Z"dd l#m$Z$ddl%m&Z&ee"e'e!fZ(ee!ge"e)effZ*dgZ+e,dej-Z.e,dZ/e,dZ0e j1e j2e j3e j4e j5e j6e j7e j8e j9e j:e j;e je j?e j@e jAgZBddeBDZCGdddeDZEGdddeDZFd6ddZGddZHd7ddZId8dd ZJd9d!d"ZKGd#d$d$eDZLd%d&ZMd'd(ZNGd)d*d*eOZPd+d,ZQd-d.ZRd/d0ZSd1d2ZTd:d3d4ZUe,d5ej-ZVdS);z Requirements file parsing )absolute_importN)parse) cmdoptions)InstallationErrorRequirementsFileParseError) SearchScope) auto_decode)MYPY_CHECK_RUNNING)get_url_scheme)Values) AnyCallableDictIteratorListNoReturnOptionalTextTuple) PackageFinder) PipSessionparse_requirementsz^(http|https|file):z (^|\s+)#.*$z#(?P\$\{(?P[A-Z0-9_]+)\})cCsg|]}t|jqS)strdest).0orr[C:\Users\vtejo\AppData\Local\Temp\pip-unpacked-wheel-6mt8ur68\pip\_internal\req\req_file.py Msrc@seZdZdddZdS)ParsedRequirementNcCs(||_||_||_||_||_||_dSN) requirement is_editable comes_fromoptions constraint line_source)selfr!r"r#r%r$r&rrr__init__Qs zParsedRequirement.__init__)NN__name__ __module__ __qualname__r(rrrrrPsrc@seZdZddZdS) ParsedLinecCs`||_||_||_||_||_|r6d|_d|_||_n&|jrVd|_d|_|jd|_nd|_dS)NTFr) filenamelinenor#optsr%is_requirementr"r! editables)r'r.r/r#argsr0r%rrrr(ds zParsedLine.__init__Nr)rrrrr-csr-Fc csHt|}t|||}|||D]"}t||||d} | dk r | Vq dS)aParse a requirements file and yield InstallRequirement 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.r5r4r#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 rFcCsd|jrdnd|j|j}|js&t|jrBt|j|j||jdS|rTt ||j i}t D],}||j j kr\|j j |r\|j j |||<q\d|j|j}t|j|j||j||dSdS)Nz{} {} (line {})z-cz-r)r!r"r#r% line {} of {})r!r"r#r%r$r&)formatr%r.r/r1AssertionErrorr"rr!rcheck_install_build_globalr0SUPPORTED_OPTIONS_REQ_DEST__dict__)liner$line_comes_from req_optionsrr&rrrhandle_requirement_lines8  rPcCs|jr|j|_n|r|j}|j}|jr.|jg}|jdkr.parse_liner)r4rrrrr6s r6cCsf|d}g}|dd}|D]2}|ds6|dr<qRq|||dqd|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 startswithr_popr])rMtokensr3r$tokenrrrrs    rc@seZdZddZdS)rycCs ||_dSr )rzr'rzrrrr(szOptionParsingError.__init__Nr)rrrrrysrycCs@tjdd}tt}|D]}|}||qdd}||_|S)z7 Return a parser for parsing requirement lines F)add_help_optioncSs t|dSr )ryrrrr parser_exitsz!build_parser..parser_exit)optparse OptionParserSUPPORTED_OPTIONSSUPPORTED_OPTIONS_REQ add_optionexit)r:option_factoriesoption_factoryoptionrrrrrs  rccsd}g}|D]v\}}|dr(t|rjt|r:d|}|r^|||d|fVg}q||fVq |sr|}||dq |r|d|fVdS)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_REmatchr_r]strip)rEprimary_line_numbernew_liner|rMrrrrAs     rAccs4|D]*\}}td|}|}|r||fVqdS)z1 Strips comments and filter empty lines. rN)rsubr)rEr|rMrrrrBs   rBccsL|D]B\}}t|D]$\}}t|}|s.q|||}q||fVqdS)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_REfindallrYgetenvreplace)rEr|rMenv_varvar_namererrrrCs  rCc Cs$t|}|dkr.||}||j|jfS|dkr|rT|drTtd|||ddd}| dd}t |}|r| dd|d dd}t |}|drd|d}|}z&t|d }t|}W5QRXWn2tk r} ztd | W5d } ~ 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/|rbz$Could not open requirements file: {}N)r getraise_for_statusurltextrrrHrr_url_slash_drive_rergrouprsunquotelstripopenrreadIOError) rr5r#schemeresprZrfrDexcrrrrxs<        rxz /*([a-z])\|)NNNF)N)NNN)NNN)N)W__doc__ __future__rrrYrerrZpip._vendor.six.moves.urllibrrsZpip._internal.clirpip._internal.exceptionsrr!pip._internal.models.search_scoperpip._internal.utils.encodingrpip._internal.utils.typingr pip._internal.utils.urlsr r typingr r rrrrrrr"pip._internal.index.package_finderrpip._internal.network.sessionrintZ ReqFileLinesrZ LineParser__all__compileIrqrrrUextra_index_urlrVrproeditablerQ no_binary only_binaryrTra trusted_host always_unziprinstall_optionsglobal_optionshashrrKobjectrr-rrFrPrir8r7r6r ExceptionryrrArBrCrxrrrrrs        ,    ! ! 0 4 -N  -