def parse_requirements(<EOL>filename,  <EOL>finder=None,  <EOL>comes_from=None,  <EOL>options=None,  <EOL>session=None,  <EOL>constraint=False,  <EOL>wheel_cache=None,  <EOL>use_pep517=None  <EOL>):<EOL>
if session is None:<EOL><INDENT>raise TypeError(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>)<EOL><DEDENT>_, content = get_file_content(<EOL>filename, comes_from=comes_from, session=session<EOL>)<EOL>lines_enum = preprocess(content, options)<EOL>for line_number, line in lines_enum:<EOL><INDENT>req_iter = process_line(line, filename, line_number, finder,<EOL>comes_from, options, session, wheel_cache,<EOL>use_pep517=use_pep517, constraint=constraint)<EOL>for req in req_iter:<EOL><INDENT>yield req<EOL><DEDENT><DEDENT>
Parse 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
    :param use_pep517:  Value of the --use-pep517 option.