def get_processed_req_from_line(line, fname='file', lineno=1): line_parser = get_line_parser(None) args_str, opts = line_parser(line) parsed_line = ParsedLine( fname, lineno, fname, args_str, opts, False, ) req = handle_line(parsed_line) assert req is not None req.is_direct = True return req
def get_processed_req_from_line(line, fname='file', lineno=1): line_parser = get_line_parser(None) args_str, opts = line_parser(line) parsed_line = ParsedLine( fname, lineno, args_str, opts, False, ) parsed_req = handle_requirement_line(parsed_line) assert parsed_req is not None req = install_req_from_parsed_requirement(parsed_req) req.user_supplied = True return req
def parse_install_requirements(requirements_lock: str, extra_pip_args: List[str]) -> List[Tuple[InstallRequirement, str]]: ps = PipSession() # This is roughly taken from pip._internal.req.req_file.parse_requirements # (https://github.com/pypa/pip/blob/21.0.1/src/pip/_internal/req/req_file.py#L127) in order to keep # the original line (sort-of, its preprocessed) from the requirements_lock file around, to pass to sub repos # as the requirement. line_parser = get_line_parser(finder=None) parser = RequirementsFileParser(ps, line_parser) install_req_and_lines: List[Tuple[InstallRequirement, str]] = [] _, content = get_file_content(requirements_lock, ps) for parsed_line, (_, line) in zip(parser.parse(requirements_lock, constraint=False), preprocess(content)): if parsed_line.is_requirement: install_req_and_lines.append( ( constructors.install_req_from_line(parsed_line.requirement), line ) ) else: extra_pip_args.extend(shlex.split(line)) return install_req_and_lines