summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavanum Srinivas <davanum@gmail.com>2015-08-23 08:48:29 -0400
committerDavanum Srinivas <davanum@gmail.com>2015-08-23 21:54:15 -0400
commit1e05037c2ae02a4d52d0f50abf00d61021971508 (patch)
tree1d25c752c297afbfe1197cd12e64ed1fbcc5a63a
parent628073a31ca2a5c27c71c129bd9583623dc2ad29 (diff)
downloadpbr-1e05037c2ae02a4d52d0f50abf00d61021971508.tar.gz
Strip comments in requirements files1.6.0
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
-rw-r--r--pbr/packaging.py1
-rw-r--r--pbr/tests/test_packaging.py12
2 files changed, 10 insertions, 3 deletions
diff --git a/pbr/packaging.py b/pbr/packaging.py
index ec4388b..672b8a7 100644
--- a/pbr/packaging.py
+++ b/pbr/packaging.py
@@ -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:
diff --git a/pbr/tests/test_packaging.py b/pbr/tests/test_packaging.py
index 4a188d0..607d63a 100644
--- a/pbr/tests/test_packaging.py
+++ b/pbr/tests/test_packaging.py
@@ -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("""\