3 ].@sxdZddlmZddlZddlZddlZddlZddlZddlZddl m Z ddl m Z ddlZddlmZddlmZddlmZdd lmZdd lmZd gZejd ejZejd Zejejejej ej!ej"ej#ej$ej%ej&ej'ej(ej)ej*ej+ej,ej-ej.ej/ej0ej1gZ2ej3ej4ej5gZ6dde6DZ7d dd Z8ddZ9d!ddZ:ddZ;ddZddZ?dS)"z Requirements file parsing )absolute_importN)parse) filterfalse)get_file_content)InstallRequirement)RequirementsFileParseError)RemovedInPip10Warning) cmdoptionsparse_requirementsz^(http|https|file):z (^|\s)+#.*$cCsg|] }|jqS)dest).0or r //tmp/pip-build-8jg9gmni/pip/pip/req/req_file.py =srFc csp|dkrtdt|||d\}}t||} x>| D]6\} } t| || ||||||d } x| D] } | VqZWq2WdS)aParse a requirements file and yield InstallRequirement instances. :param filename: Path or url of requirements file. :param finder: Instance of pip.index.PackageFinder. :param comes_from: Origin description of requirements. :param options: cli options. :param session: Instance of pip.download.PipSession. :param constraint: If true, parsing a constraint file rather than requirements file. :param wheel_cache: Instance of pip.wheel.WheelCache NzCparse_requirements() missing 1 required keyword argument: 'session') comes_fromsession) constraint) TypeErrorr preprocess process_line)filenamefinderroptionsrr wheel_cache_content lines_enum line_numberlinereq_iterreqr r rr @s    cCs.t|jdd}t|}t|}t||}|S)zSplit, filter, and join lines, and return a line iterator :param content: the content of the requirements file :param options: cli options )start) enumerate splitlines join_linesignore_comments skip_regex)rrrr r rras  rc  cs t} | j} d| _|r |j| _t|\} } tjdkr@| jd} | jt j | | \} }d|r`dnd||f}| r|rz|j nd }|rt j || i}x.tD]&}|| jkr| j|r| j|||<qWtj| |||||d Vn(| jr&|r|j nd }|r|jnd}tj| jd |||||d Vn| js6| jr| jrN| jd }d }n| jd }d }tj|rvtj||}n"tj|stjjtjj||}t|||||||d} x| D] }|VqWn>| j r| j |_ n*|r| j!rt"j#dt$| j%r t"j#dt$| j&rt"j#dt$| jr0| jg|_'| j(d krPd |_(t)j*j+|j| j,d krbg|_'| j-rx|j'j.| j-| j/r| j/d }tjjtjj0|}tjj||}tjj1|r|}|j/j2|| j3rd |_4| j5rd |_5| j6r|j7j.dd| j6DdS)a#Process a single requirements line; This can result in creating/yielding requirements, or updating the finder. 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. :param constraint: If True, parsing a constraints file. :param options: OptionParser options that we may update Nutf8z%s %s (line %s)z-cz-rF)risolatedrrr)rr default_vcsr-rT)rrz--allow-external has been deprecated and will be removed in the future. Due to changes in the repository protocol, it no longer has any effect.z--allow-all-external has been deprecated and will be removed in the future. Due to changes in the repository protocol, it no longer has any effect.z--allow-unverified has been deprecated and will be removed in the future. Due to changes in the repository protocol, it no longer has any effect.css|]}d|dfVqdS)*Nr )r hostr r r szprocess_line..)r)r*r+)8 build_parserget_default_values index_urlformat_controlbreak_args_optionssys version_infoencode parse_argsshlexsplit isolated_moder check_install_build_globalSUPPORTED_OPTIONS_REQ_DEST__dict__r from_line editablesr. from_editable requirements constraints SCHEME_REsearch urllib_parseurljoinospathjoindirnamer require_hashesallow_externalwarningswarnrallow_all_externalallow_unverified index_urls use_wheelpipindexfmt_ctl_no_use_wheelno_indexextra_index_urlsextend find_linksabspathexistsappendpreallow_all_prereleasesprocess_dependency_links trusted_hostssecure_origins)rrrrrrrrrparserdefaultsargs_str options_stroptsrline_comes_fromr- req_optionsr r.req_pathnested_constraintr!valuereq_dirrelative_to_reqs_filer r rrns                   rcCsh|jd}g}|dd}x8|D]0}|jds8|jdr.parser_exit)optparse OptionParserSUPPORTED_OPTIONSSUPPORTED_OPTIONS_REQ add_optionexit)reoption_factoriesoption_factoryoptionr{r r rr2s  r2ccsd}g}x|D]x\}}|jd s,tj|rntj|r>d|}|rb|j||dj|fVg}q||fVq|sv|}|j|jdqW|r|dj|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\rq)endswith COMMENT_REmatchr_rLstrip)rprimary_line_numbernew_linerrr r rr&"s    r&ccs8x2|D]*\}}tjd|}|j}|r||fVqWdS)z1 Strips comments and filter empty lines. rN)rsubr)rrrr r rr'?s  r'cs2|r |jnd}|r.tj|tfdd|}|S)zs Skip lines that match '--skip-requirements-regex' pattern Note: the regex pattern is only built once Ncsj|dS)Nr")rG)e)patternr rTszskip_regex..)skip_requirements_regexrecompiler)rrr(r )rrr(Js  r()NNNNFN)NNNNNF)@__doc__ __future__rrJrr;r7r|rPZpip._vendor.six.moves.urllibrrHZpip._vendor.six.movesrrV pip.downloadrZpip.req.req_installrpip.exceptionsrZpip.utils.deprecationrr __all__rIrFrrEeditablerDrYr4r\extra_index_urlrOrRno_allow_external allow_unsafeno_allow_unsaferU no_use_wheel always_unzip no_binary only_binaryr`rb trusted_hostrNr~install_optionsglobal_optionshashrr?r rrr6r2r&r'r(r r r rsn