We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
pip install --allow-all-external in requirements.txt file fails
**With pip 7**
requirements.txt file:

``` txt
--allow-all-external
mysql-connector-python
```

On comandline

``` bash
pip install -r requirements.txt 
pip: error: no such option: --allow-all-external
```

**With pip 6.1.1**
Collecting mysql-connector-python (from -r requirements.txt (line 2))
  Downloading http://cdn.mysql.com/Downloads/Connector-Python/mysql-connector-python-2.0.3.zip (275kB)
    100% |████████████████████████████████| 278kB 3.0MB/s 
Installing collected packages: mysql-connector-python
  Running setup.py install for mysql-connector-python
Successfully installed mysql-connector-python-2.0.3


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `pip/req/req_file.py`
Content:
```
1 """
2 Requirements file parsing
3 """
4 
5 from __future__ import absolute_import
6 
7 import os
8 import re
9 import shlex
10 import optparse
11 
12 from pip._vendor.six.moves.urllib import parse as urllib_parse
13 from pip._vendor.six.moves import filterfalse
14 
15 import pip
16 from pip.download import get_file_content
17 from pip.req.req_install import InstallRequirement
18 from pip.exceptions import (RequirementsFileParseError)
19 from pip.utils import normalize_name
20 from pip import cmdoptions
21 
22 __all__ = ['parse_requirements']
23 
24 SCHEME_RE = re.compile(r'^(http|https|file):', re.I)
25 COMMENT_RE = re.compile(r'(^|\s)+#.*$')
26 
27 SUPPORTED_OPTIONS = [
28     cmdoptions.editable,
29     cmdoptions.requirements,
30     cmdoptions.no_index,
31     cmdoptions.index_url,
32     cmdoptions.find_links,
33     cmdoptions.extra_index_url,
34     cmdoptions.allow_external,
35     cmdoptions.no_allow_external,
36     cmdoptions.allow_unsafe,
37     cmdoptions.no_allow_unsafe,
38     cmdoptions.use_wheel,
39     cmdoptions.no_use_wheel,
40     cmdoptions.always_unzip,
41     cmdoptions.no_binary,
42     cmdoptions.only_binary,
43 ]
44 
45 # options to be passed to requirements
46 SUPPORTED_OPTIONS_REQ = [
47     cmdoptions.install_options,
48     cmdoptions.global_options
49 ]
50 
51 # the 'dest' string values
52 SUPPORTED_OPTIONS_REQ_DEST = [o().dest for o in SUPPORTED_OPTIONS_REQ]
53 
54 
55 def parse_requirements(filename, finder=None, comes_from=None, options=None,
56                        session=None, wheel_cache=None):
57     """
58     Parse a requirements file and yield InstallRequirement instances.
59 
60     :param filename:    Path or url of requirements file.
61     :param finder:      Instance of pip.index.PackageFinder.
62     :param comes_from:  Origin description of requirements.
63     :param options:     Global options.
64     :param session:     Instance of pip.download.PipSession.
65     :param wheel_cache: Instance of pip.wheel.WheelCache
66     """
67     if session is None:
68         raise TypeError(
69             "parse_requirements() missing 1 required keyword argument: "
70             "'session'"
71         )
72 
73     _, content = get_file_content(
74         filename, comes_from=comes_from, session=session
75     )
76 
77     lines = content.splitlines()
78     lines = ignore_comments(lines)
79     lines = join_lines(lines)
80     lines = skip_regex(lines, options)
81 
82     for line_number, line in enumerate(lines, 1):
83         req_iter = process_line(line, filename, line_number, finder,
84                                 comes_from, options, session, wheel_cache)
85         for req in req_iter:
86             yield req
87 
88 
89 def process_line(line, filename, line_number, finder=None, comes_from=None,
90                  options=None, session=None, wheel_cache=None):
91     """Process a single requirements line; This can result in creating/yielding
92     requirements, or updating the finder.
93 
94     For lines that contain requirements, the only options that have an effect
95     are from SUPPORTED_OPTIONS_REQ, and they are scoped to the
96     requirement. Other options from SUPPORTED_OPTIONS may be present, but are
97     ignored.
98 
99     For lines that do not contain requirements, the only options that have an
100     effect are from SUPPORTED_OPTIONS. Options from SUPPORTED_OPTIONS_REQ may
101     be present, but are ignored. These lines may contain multiple options
102     (although our docs imply only one is supported), and all our parsed and
103     affect the finder.
104 
105     """
106 
107     parser = build_parser()
108     defaults = parser.get_default_values()
109     defaults.index_url = None
110     if finder:
111         # `finder.format_control` will be updated during parsing
112         defaults.format_control = finder.format_control
113     opts, args = parser.parse_args(shlex.split(line), defaults)
114 
115     # yield a line requirement
116     if args:
117         args_line = ' '.join(args)
118         comes_from = '-r %s (line %s)' % (filename, line_number)
119         isolated = options.isolated_mode if options else False
120         if options:
121             cmdoptions.check_install_build_global(options, opts)
122         # get the options that apply to requirements
123         req_options = {}
124         for dest in SUPPORTED_OPTIONS_REQ_DEST:
125             if dest in opts.__dict__ and opts.__dict__[dest]:
126                 req_options[dest] = opts.__dict__[dest]
127         yield InstallRequirement.from_line(
128             args_line, comes_from, isolated=isolated, options=req_options,
129             wheel_cache=wheel_cache
130         )
131 
132     # yield an editable requirement
133     elif opts.editables:
134         comes_from = '-r %s (line %s)' % (filename, line_number)
135         isolated = options.isolated_mode if options else False
136         default_vcs = options.default_vcs if options else None
137         yield InstallRequirement.from_editable(
138             opts.editables[0], comes_from=comes_from,
139             default_vcs=default_vcs, isolated=isolated,
140             wheel_cache=wheel_cache
141         )
142 
143     # parse a nested requirements file
144     elif opts.requirements:
145         req_path = opts.requirements[0]
146         # original file is over http
147         if SCHEME_RE.search(filename):
148             # do a url join so relative paths work
149             req_path = urllib_parse.urljoin(filename, req_path)
150         # original file and nested file are paths
151         elif not SCHEME_RE.search(req_path):
152             # do a join so relative paths work
153             req_dir = os.path.dirname(filename)
154             req_path = os.path.join(os.path.dirname(filename), req_path)
155         # TODO: Why not use `comes_from='-r {} (line {})'` here as well?
156         parser = parse_requirements(
157             req_path, finder, comes_from, options, session,
158             wheel_cache=wheel_cache
159         )
160         for req in parser:
161             yield req
162 
163     # set finder options
164     elif finder:
165         if opts.index_url:
166             finder.index_urls = [opts.index_url]
167         if opts.use_wheel is False:
168             finder.use_wheel = False
169             pip.index.fmt_ctl_no_use_wheel(finder.format_control)
170         if opts.no_index is True:
171             finder.index_urls = []
172         if opts.allow_all_external:
173             finder.allow_all_external = opts.allow_all_external
174         if opts.extra_index_urls:
175             finder.index_urls.extend(opts.extra_index_urls)
176         if opts.allow_external:
177             finder.allow_external |= set(
178                 [normalize_name(v).lower() for v in opts.allow_external])
179         if opts.allow_unverified:
180             # Remove after 7.0
181             finder.allow_unverified |= set(
182                 [normalize_name(v).lower() for v in opts.allow_unverified])
183         if opts.find_links:
184             # FIXME: it would be nice to keep track of the source
185             # of the find_links: support a find-links local path
186             # relative to a requirements file.
187             value = opts.find_links[0]
188             req_dir = os.path.dirname(os.path.abspath(filename))
189             relative_to_reqs_file = os.path.join(req_dir, value)
190             if os.path.exists(relative_to_reqs_file):
191                 value = relative_to_reqs_file
192             finder.find_links.append(value)
193 
194 
195 def build_parser():
196     """
197     Return a parser for parsing requirement lines
198     """
199     parser = optparse.OptionParser(add_help_option=False)
200 
201     option_factories = SUPPORTED_OPTIONS + SUPPORTED_OPTIONS_REQ
202     for option_factory in option_factories:
203         option = option_factory()
204         parser.add_option(option)
205 
206     # By default optparse sys.exits on parsing errors. We want to wrap
207     # that in our own exception.
208     def parser_exit(self, msg):
209         raise RequirementsFileParseError(msg)
210     parser.exit = parser_exit
211 
212     return parser
213 
214 
215 def join_lines(iterator):
216     """
217     Joins a line ending in '\' with the previous line.
218     """
219     lines = []
220     for line in iterator:
221         if not line.endswith('\\'):
222             if lines:
223                 lines.append(line)
224                 yield ''.join(lines)
225                 lines = []
226             else:
227                 yield line
228         else:
229             lines.append(line.strip('\\'))
230 
231     # TODO: handle space after '\'.
232     # TODO: handle '\' on last line.
233 
234 
235 def ignore_comments(iterator):
236     """
237     Strips and filters empty or commented lines.
238     """
239     for line in iterator:
240         line = COMMENT_RE.sub('', line)
241         line = line.strip()
242         if line:
243             yield line
244 
245 
246 def skip_regex(lines, options):
247     """
248     Optionally exclude lines that match '--skip-requirements-regex'
249     """
250     skip_regex = options.skip_requirements_regex if options else None
251     if skip_regex:
252         lines = filterfalse(re.compile(skip_regex).search, lines)
253     return lines
254
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/pip/req/req_file.py b/pip/req/req_file.py
--- a/pip/req/req_file.py
+++ b/pip/req/req_file.py
@@ -32,6 +32,7 @@
     cmdoptions.find_links,
     cmdoptions.extra_index_url,
     cmdoptions.allow_external,
+    cmdoptions.allow_all_external,
     cmdoptions.no_allow_external,
     cmdoptions.allow_unsafe,
     cmdoptions.no_allow_unsafe,

{"golden_diff": "diff --git a/pip/req/req_file.py b/pip/req/req_file.py\n--- a/pip/req/req_file.py\n+++ b/pip/req/req_file.py\n@@ -32,6 +32,7 @@\n     cmdoptions.find_links,\n     cmdoptions.extra_index_url,\n     cmdoptions.allow_external,\n+    cmdoptions.allow_all_external,\n     cmdoptions.no_allow_external,\n     cmdoptions.allow_unsafe,\n     cmdoptions.no_allow_unsafe,\n", "issue": "pip install --allow-all-external in requirements.txt file fails\n**With pip 7**\nrequirements.txt file:\n\n``` txt\n--allow-all-external\nmysql-connector-python\n```\n\nOn comandline\n\n``` bash\npip install -r requirements.txt \npip: error: no such option: --allow-all-external\n```\n\n**With pip 6.1.1**\nCollecting mysql-connector-python (from -r requirements.txt (line 2))\n  Downloading http://cdn.mysql.com/Downloads/Connector-Python/mysql-connector-python-2.0.3.zip (275kB)\n    100% |\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588| 278kB 3.0MB/s \nInstalling collected packages: mysql-connector-python\n  Running setup.py install for mysql-connector-python\nSuccessfully installed mysql-connector-python-2.0.3\n\n", "before_files": [{"content": "\"\"\"\nRequirements file parsing\n\"\"\"\n\nfrom __future__ import absolute_import\n\nimport os\nimport re\nimport shlex\nimport optparse\n\nfrom pip._vendor.six.moves.urllib import parse as urllib_parse\nfrom pip._vendor.six.moves import filterfalse\n\nimport pip\nfrom pip.download import get_file_content\nfrom pip.req.req_install import InstallRequirement\nfrom pip.exceptions import (RequirementsFileParseError)\nfrom pip.utils import normalize_name\nfrom pip import cmdoptions\n\n__all__ = ['parse_requirements']\n\nSCHEME_RE = re.compile(r'^(http|https|file):', re.I)\nCOMMENT_RE = re.compile(r'(^|\\s)+#.*$')\n\nSUPPORTED_OPTIONS = [\n    cmdoptions.editable,\n    cmdoptions.requirements,\n    cmdoptions.no_index,\n    cmdoptions.index_url,\n    cmdoptions.find_links,\n    cmdoptions.extra_index_url,\n    cmdoptions.allow_external,\n    cmdoptions.no_allow_external,\n    cmdoptions.allow_unsafe,\n    cmdoptions.no_allow_unsafe,\n    cmdoptions.use_wheel,\n    cmdoptions.no_use_wheel,\n    cmdoptions.always_unzip,\n    cmdoptions.no_binary,\n    cmdoptions.only_binary,\n]\n\n# options to be passed to requirements\nSUPPORTED_OPTIONS_REQ = [\n    cmdoptions.install_options,\n    cmdoptions.global_options\n]\n\n# the 'dest' string values\nSUPPORTED_OPTIONS_REQ_DEST = [o().dest for o in SUPPORTED_OPTIONS_REQ]\n\n\ndef parse_requirements(filename, finder=None, comes_from=None, options=None,\n                       session=None, wheel_cache=None):\n    \"\"\"\n    Parse a requirements file and yield InstallRequirement instances.\n\n    :param filename:    Path or url of requirements file.\n    :param finder:      Instance of pip.index.PackageFinder.\n    :param comes_from:  Origin description of requirements.\n    :param options:     Global options.\n    :param session:     Instance of pip.download.PipSession.\n    :param wheel_cache: Instance of pip.wheel.WheelCache\n    \"\"\"\n    if session is None:\n        raise TypeError(\n            \"parse_requirements() missing 1 required keyword argument: \"\n            \"'session'\"\n        )\n\n    _, content = get_file_content(\n        filename, comes_from=comes_from, session=session\n    )\n\n    lines = content.splitlines()\n    lines = ignore_comments(lines)\n    lines = join_lines(lines)\n    lines = skip_regex(lines, options)\n\n    for line_number, line in enumerate(lines, 1):\n        req_iter = process_line(line, filename, line_number, finder,\n                                comes_from, options, session, wheel_cache)\n        for req in req_iter:\n            yield req\n\n\ndef process_line(line, filename, line_number, finder=None, comes_from=None,\n                 options=None, session=None, wheel_cache=None):\n    \"\"\"Process a single requirements line; This can result in creating/yielding\n    requirements, or updating the finder.\n\n    For lines that contain requirements, the only options that have an effect\n    are from SUPPORTED_OPTIONS_REQ, and they are scoped to the\n    requirement. Other options from SUPPORTED_OPTIONS may be present, but are\n    ignored.\n\n    For lines that do not contain requirements, the only options that have an\n    effect are from SUPPORTED_OPTIONS. Options from SUPPORTED_OPTIONS_REQ may\n    be present, but are ignored. These lines may contain multiple options\n    (although our docs imply only one is supported), and all our parsed and\n    affect the finder.\n\n    \"\"\"\n\n    parser = build_parser()\n    defaults = parser.get_default_values()\n    defaults.index_url = None\n    if finder:\n        # `finder.format_control` will be updated during parsing\n        defaults.format_control = finder.format_control\n    opts, args = parser.parse_args(shlex.split(line), defaults)\n\n    # yield a line requirement\n    if args:\n        args_line = ' '.join(args)\n        comes_from = '-r %s (line %s)' % (filename, line_number)\n        isolated = options.isolated_mode if options else False\n        if options:\n            cmdoptions.check_install_build_global(options, opts)\n        # get the options that apply to requirements\n        req_options = {}\n        for dest in SUPPORTED_OPTIONS_REQ_DEST:\n            if dest in opts.__dict__ and opts.__dict__[dest]:\n                req_options[dest] = opts.__dict__[dest]\n        yield InstallRequirement.from_line(\n            args_line, comes_from, isolated=isolated, options=req_options,\n            wheel_cache=wheel_cache\n        )\n\n    # yield an editable requirement\n    elif opts.editables:\n        comes_from = '-r %s (line %s)' % (filename, line_number)\n        isolated = options.isolated_mode if options else False\n        default_vcs = options.default_vcs if options else None\n        yield InstallRequirement.from_editable(\n            opts.editables[0], comes_from=comes_from,\n            default_vcs=default_vcs, isolated=isolated,\n            wheel_cache=wheel_cache\n        )\n\n    # parse a nested requirements file\n    elif opts.requirements:\n        req_path = opts.requirements[0]\n        # original file is over http\n        if SCHEME_RE.search(filename):\n            # do a url join so relative paths work\n            req_path = urllib_parse.urljoin(filename, req_path)\n        # original file and nested file are paths\n        elif not SCHEME_RE.search(req_path):\n            # do a join so relative paths work\n            req_dir = os.path.dirname(filename)\n            req_path = os.path.join(os.path.dirname(filename), req_path)\n        # TODO: Why not use `comes_from='-r {} (line {})'` here as well?\n        parser = parse_requirements(\n            req_path, finder, comes_from, options, session,\n            wheel_cache=wheel_cache\n        )\n        for req in parser:\n            yield req\n\n    # set finder options\n    elif finder:\n        if opts.index_url:\n            finder.index_urls = [opts.index_url]\n        if opts.use_wheel is False:\n            finder.use_wheel = False\n            pip.index.fmt_ctl_no_use_wheel(finder.format_control)\n        if opts.no_index is True:\n            finder.index_urls = []\n        if opts.allow_all_external:\n            finder.allow_all_external = opts.allow_all_external\n        if opts.extra_index_urls:\n            finder.index_urls.extend(opts.extra_index_urls)\n        if opts.allow_external:\n            finder.allow_external |= set(\n                [normalize_name(v).lower() for v in opts.allow_external])\n        if opts.allow_unverified:\n            # Remove after 7.0\n            finder.allow_unverified |= set(\n                [normalize_name(v).lower() for v in opts.allow_unverified])\n        if opts.find_links:\n            # FIXME: it would be nice to keep track of the source\n            # of the find_links: support a find-links local path\n            # relative to a requirements file.\n            value = opts.find_links[0]\n            req_dir = os.path.dirname(os.path.abspath(filename))\n            relative_to_reqs_file = os.path.join(req_dir, value)\n            if os.path.exists(relative_to_reqs_file):\n                value = relative_to_reqs_file\n            finder.find_links.append(value)\n\n\ndef build_parser():\n    \"\"\"\n    Return a parser for parsing requirement lines\n    \"\"\"\n    parser = optparse.OptionParser(add_help_option=False)\n\n    option_factories = SUPPORTED_OPTIONS + SUPPORTED_OPTIONS_REQ\n    for option_factory in option_factories:\n        option = option_factory()\n        parser.add_option(option)\n\n    # By default optparse sys.exits on parsing errors. We want to wrap\n    # that in our own exception.\n    def parser_exit(self, msg):\n        raise RequirementsFileParseError(msg)\n    parser.exit = parser_exit\n\n    return parser\n\n\ndef join_lines(iterator):\n    \"\"\"\n    Joins a line ending in '\\' with the previous line.\n    \"\"\"\n    lines = []\n    for line in iterator:\n        if not line.endswith('\\\\'):\n            if lines:\n                lines.append(line)\n                yield ''.join(lines)\n                lines = []\n            else:\n                yield line\n        else:\n            lines.append(line.strip('\\\\'))\n\n    # TODO: handle space after '\\'.\n    # TODO: handle '\\' on last line.\n\n\ndef ignore_comments(iterator):\n    \"\"\"\n    Strips and filters empty or commented lines.\n    \"\"\"\n    for line in iterator:\n        line = COMMENT_RE.sub('', line)\n        line = line.strip()\n        if line:\n            yield line\n\n\ndef skip_regex(lines, options):\n    \"\"\"\n    Optionally exclude lines that match '--skip-requirements-regex'\n    \"\"\"\n    skip_regex = options.skip_requirements_regex if options else None\n    if skip_regex:\n        lines = filterfalse(re.compile(skip_regex).search, lines)\n    return lines\n", "path": "pip/req/req_file.py"}], "after_files": [{"content": "\"\"\"\nRequirements file parsing\n\"\"\"\n\nfrom __future__ import absolute_import\n\nimport os\nimport re\nimport shlex\nimport optparse\n\nfrom pip._vendor.six.moves.urllib import parse as urllib_parse\nfrom pip._vendor.six.moves import filterfalse\n\nimport pip\nfrom pip.download import get_file_content\nfrom pip.req.req_install import InstallRequirement\nfrom pip.exceptions import (RequirementsFileParseError)\nfrom pip.utils import normalize_name\nfrom pip import cmdoptions\n\n__all__ = ['parse_requirements']\n\nSCHEME_RE = re.compile(r'^(http|https|file):', re.I)\nCOMMENT_RE = re.compile(r'(^|\\s)+#.*$')\n\nSUPPORTED_OPTIONS = [\n    cmdoptions.editable,\n    cmdoptions.requirements,\n    cmdoptions.no_index,\n    cmdoptions.index_url,\n    cmdoptions.find_links,\n    cmdoptions.extra_index_url,\n    cmdoptions.allow_external,\n    cmdoptions.allow_all_external,\n    cmdoptions.no_allow_external,\n    cmdoptions.allow_unsafe,\n    cmdoptions.no_allow_unsafe,\n    cmdoptions.use_wheel,\n    cmdoptions.no_use_wheel,\n    cmdoptions.always_unzip,\n    cmdoptions.no_binary,\n    cmdoptions.only_binary,\n]\n\n# options to be passed to requirements\nSUPPORTED_OPTIONS_REQ = [\n    cmdoptions.install_options,\n    cmdoptions.global_options\n]\n\n# the 'dest' string values\nSUPPORTED_OPTIONS_REQ_DEST = [o().dest for o in SUPPORTED_OPTIONS_REQ]\n\n\ndef parse_requirements(filename, finder=None, comes_from=None, options=None,\n                       session=None, wheel_cache=None):\n    \"\"\"\n    Parse a requirements file and yield InstallRequirement instances.\n\n    :param filename:    Path or url of requirements file.\n    :param finder:      Instance of pip.index.PackageFinder.\n    :param comes_from:  Origin description of requirements.\n    :param options:     Global options.\n    :param session:     Instance of pip.download.PipSession.\n    :param wheel_cache: Instance of pip.wheel.WheelCache\n    \"\"\"\n    if session is None:\n        raise TypeError(\n            \"parse_requirements() missing 1 required keyword argument: \"\n            \"'session'\"\n        )\n\n    _, content = get_file_content(\n        filename, comes_from=comes_from, session=session\n    )\n\n    lines = content.splitlines()\n    lines = ignore_comments(lines)\n    lines = join_lines(lines)\n    lines = skip_regex(lines, options)\n\n    for line_number, line in enumerate(lines, 1):\n        req_iter = process_line(line, filename, line_number, finder,\n                                comes_from, options, session, wheel_cache)\n        for req in req_iter:\n            yield req\n\n\ndef process_line(line, filename, line_number, finder=None, comes_from=None,\n                 options=None, session=None, wheel_cache=None):\n    \"\"\"Process a single requirements line; This can result in creating/yielding\n    requirements, or updating the finder.\n\n    For lines that contain requirements, the only options that have an effect\n    are from SUPPORTED_OPTIONS_REQ, and they are scoped to the\n    requirement. Other options from SUPPORTED_OPTIONS may be present, but are\n    ignored.\n\n    For lines that do not contain requirements, the only options that have an\n    effect are from SUPPORTED_OPTIONS. Options from SUPPORTED_OPTIONS_REQ may\n    be present, but are ignored. These lines may contain multiple options\n    (although our docs imply only one is supported), and all our parsed and\n    affect the finder.\n\n    \"\"\"\n\n    parser = build_parser()\n    defaults = parser.get_default_values()\n    defaults.index_url = None\n    if finder:\n        # `finder.format_control` will be updated during parsing\n        defaults.format_control = finder.format_control\n    opts, args = parser.parse_args(shlex.split(line), defaults)\n\n    # yield a line requirement\n    if args:\n        args_line = ' '.join(args)\n        comes_from = '-r %s (line %s)' % (filename, line_number)\n        isolated = options.isolated_mode if options else False\n        if options:\n            cmdoptions.check_install_build_global(options, opts)\n        # get the options that apply to requirements\n        req_options = {}\n        for dest in SUPPORTED_OPTIONS_REQ_DEST:\n            if dest in opts.__dict__ and opts.__dict__[dest]:\n                req_options[dest] = opts.__dict__[dest]\n        yield InstallRequirement.from_line(\n            args_line, comes_from, isolated=isolated, options=req_options,\n            wheel_cache=wheel_cache\n        )\n\n    # yield an editable requirement\n    elif opts.editables:\n        comes_from = '-r %s (line %s)' % (filename, line_number)\n        isolated = options.isolated_mode if options else False\n        default_vcs = options.default_vcs if options else None\n        yield InstallRequirement.from_editable(\n            opts.editables[0], comes_from=comes_from,\n            default_vcs=default_vcs, isolated=isolated,\n            wheel_cache=wheel_cache\n        )\n\n    # parse a nested requirements file\n    elif opts.requirements:\n        req_path = opts.requirements[0]\n        # original file is over http\n        if SCHEME_RE.search(filename):\n            # do a url join so relative paths work\n            req_path = urllib_parse.urljoin(filename, req_path)\n        # original file and nested file are paths\n        elif not SCHEME_RE.search(req_path):\n            # do a join so relative paths work\n            req_dir = os.path.dirname(filename)\n            req_path = os.path.join(os.path.dirname(filename), req_path)\n        # TODO: Why not use `comes_from='-r {} (line {})'` here as well?\n        parser = parse_requirements(\n            req_path, finder, comes_from, options, session,\n            wheel_cache=wheel_cache\n        )\n        for req in parser:\n            yield req\n\n    # set finder options\n    elif finder:\n        if opts.index_url:\n            finder.index_urls = [opts.index_url]\n        if opts.use_wheel is False:\n            finder.use_wheel = False\n            pip.index.fmt_ctl_no_use_wheel(finder.format_control)\n        if opts.no_index is True:\n            finder.index_urls = []\n        if opts.allow_all_external:\n            finder.allow_all_external = opts.allow_all_external\n        if opts.extra_index_urls:\n            finder.index_urls.extend(opts.extra_index_urls)\n        if opts.allow_external:\n            finder.allow_external |= set(\n                [normalize_name(v).lower() for v in opts.allow_external])\n        if opts.allow_unverified:\n            # Remove after 7.0\n            finder.allow_unverified |= set(\n                [normalize_name(v).lower() for v in opts.allow_unverified])\n        if opts.find_links:\n            # FIXME: it would be nice to keep track of the source\n            # of the find_links: support a find-links local path\n            # relative to a requirements file.\n            value = opts.find_links[0]\n            req_dir = os.path.dirname(os.path.abspath(filename))\n            relative_to_reqs_file = os.path.join(req_dir, value)\n            if os.path.exists(relative_to_reqs_file):\n                value = relative_to_reqs_file\n            finder.find_links.append(value)\n\n\ndef build_parser():\n    \"\"\"\n    Return a parser for parsing requirement lines\n    \"\"\"\n    parser = optparse.OptionParser(add_help_option=False)\n\n    option_factories = SUPPORTED_OPTIONS + SUPPORTED_OPTIONS_REQ\n    for option_factory in option_factories:\n        option = option_factory()\n        parser.add_option(option)\n\n    # By default optparse sys.exits on parsing errors. We want to wrap\n    # that in our own exception.\n    def parser_exit(self, msg):\n        raise RequirementsFileParseError(msg)\n    parser.exit = parser_exit\n\n    return parser\n\n\ndef join_lines(iterator):\n    \"\"\"\n    Joins a line ending in '\\' with the previous line.\n    \"\"\"\n    lines = []\n    for line in iterator:\n        if not line.endswith('\\\\'):\n            if lines:\n                lines.append(line)\n                yield ''.join(lines)\n                lines = []\n            else:\n                yield line\n        else:\n            lines.append(line.strip('\\\\'))\n\n    # TODO: handle space after '\\'.\n    # TODO: handle '\\' on last line.\n\n\ndef ignore_comments(iterator):\n    \"\"\"\n    Strips and filters empty or commented lines.\n    \"\"\"\n    for line in iterator:\n        line = COMMENT_RE.sub('', line)\n        line = line.strip()\n        if line:\n            yield line\n\n\ndef skip_regex(lines, options):\n    \"\"\"\n    Optionally exclude lines that match '--skip-requirements-regex'\n    \"\"\"\n    skip_regex = options.skip_requirements_regex if options else None\n    if skip_regex:\n        lines = filterfalse(re.compile(skip_regex).search, lines)\n    return lines\n", "path": "pip/req/req_file.py"}]}