From daa905cad45ea89b557b6468af021270980b9c24 Mon Sep 17 00:00:00 2001 From: Sachi King Date: Fri, 11 Sep 2015 17:57:23 +1000 Subject: Strip comments present in setup.cfg When processing setup.cfg strip trailing comments from lines as this is unsupported by setuptools. Change-Id: I7712c07552b50830549644a6ff4167b90d897125 Closes-bug: 1494330 --- pbr/tests/test_packaging.py | 5 +++-- pbr/util.py | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pbr/tests/test_packaging.py b/pbr/tests/test_packaging.py index 607d63a..9e56fd8 100644 --- a/pbr/tests/test_packaging.py +++ b/pbr/tests/test_packaging.py @@ -479,7 +479,8 @@ class TestRequirementParsing(base.BaseTestCase): [extras] test = foo - baz>3.2 :python_version=='2.7' + baz>3.2 :python_version=='2.7' # MIT + bar>3.3 :python_version=='2.7' # MIT # Apache """))) # pkg_resources.split_sections uses None as the title of an # anonymous section instead of the empty string. Weird. @@ -489,7 +490,7 @@ class TestRequirementParsing(base.BaseTestCase): ":(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'] + "test:(python_version=='2.7')": ['baz>3.2', 'bar>3.3'] } setup_py = os.path.join(tempdir, 'setup.py') diff --git a/pbr/util.py b/pbr/util.py index 644bcd8..fffd733 100644 --- a/pbr/util.py +++ b/pbr/util.py @@ -334,7 +334,7 @@ def setup_cfg_to_setup_kwargs(config): # Split install_requires into package,env_marker tuples # These will be re-assembled later install_requires = [] - requirement_pattern = '(?P[^;]*);?(?P.*)$' + requirement_pattern = '(?P[^;]*);?(?P[^#]*?)(?:\s*#.*)?$' for requirement in in_cfg_value: m = re.match(requirement_pattern, requirement) requirement_package = m.group('package').strip() @@ -394,7 +394,7 @@ def setup_cfg_to_setup_kwargs(config): # -> {'fred': ['bar'], 'fred:marker':['foo']} if 'extras' in config: - requirement_pattern = '(?P[^:]*):?(?P.*)$' + requirement_pattern = '(?P[^:]*):?(?P[^#]*?)(?:\s*#.*)?$' extras = config['extras'] for extra in extras: extra_requirements = [] -- cgit v1.2.1