Strip comments in requirements files
Since we don't strip comments from end of the requirements like: requests-kerberos>=0.6;python_version=='2.7' # MIT The currnet code ends up failing with a: "Invalid environment marker" We should strip the comments out before processing. Closes-Bug: #1487835 Change-Id: I75d2e83a5f60f93e1c38d53fb4f0a29ba35120b1
This commit is contained in:
parent
628073a31c
commit
1e05037c2a
|
@ -132,6 +132,7 @@ def parse_requirements(requirements_files=None, strip_markers=False):
|
|||
reason = 'Index Location'
|
||||
|
||||
if line is not None:
|
||||
line = re.sub('#.*$', '', line)
|
||||
if strip_markers:
|
||||
semi_pos = line.find(';')
|
||||
if semi_pos < 0:
|
||||
|
|
|
@ -466,6 +466,9 @@ class TestRequirementParsing(base.BaseTestCase):
|
|||
f.write(textwrap.dedent(six.u("""\
|
||||
bar
|
||||
quux<1.0; python_version=='2.6'
|
||||
requests-aws>=0.1.4 # BSD License (3 clause)
|
||||
Routes>=1.12.3,!=2.0,!=2.1;python_version=='2.7'
|
||||
requests-kerberos>=0.6;python_version=='2.7' # MIT
|
||||
""")))
|
||||
setup_cfg = os.path.join(tempdir, 'setup.cfg')
|
||||
with open(setup_cfg, 'wt') as f:
|
||||
|
@ -481,11 +484,14 @@ class TestRequirementParsing(base.BaseTestCase):
|
|||
# pkg_resources.split_sections uses None as the title of an
|
||||
# anonymous section instead of the empty string. Weird.
|
||||
expected_requirements = {
|
||||
None: ['bar'],
|
||||
None: ['bar', 'requests-aws>=0.1.4'],
|
||||
":(python_version=='2.6')": ['quux<1.0'],
|
||||
"test:(python_version=='2.7')": ['baz>3.2'],
|
||||
"test": ['foo']
|
||||
":(python_version=='2.7')": ['Routes>=1.12.3,!=2.0,!=2.1',
|
||||
'requests-kerberos>=0.6'],
|
||||
'test': ['foo'],
|
||||
"test:(python_version=='2.7')": ['baz>3.2']
|
||||
}
|
||||
|
||||
setup_py = os.path.join(tempdir, 'setup.py')
|
||||
with open(setup_py, 'wt') as f:
|
||||
f.write(textwrap.dedent(six.u("""\
|
||||
|
|
Loading…
Reference in New Issue