Skip to content

Commit 4b15038

Browse files
committed
Strip markers from test requirements.
Setuptools doesn't [yet] support markeres in tests_require parameters to setup(). While we need to get that fixed, we also need to support syncing marker constrained requirements from global-requirements. Since version constraints are needed to successfully port to Python3 this won't be a long term viable solution: but few of our test-only dependencies require version constraints, so we can do this in the interim. The ones that do - such as python-mysql - we're either moving away from, or centralising them into optional dependencies on other packages where the tests_require limitation shouldn't apply. Change-Id: I31adaf35c8d7b72fe3f8c9242cc356fe34d537e8
1 parent e41a918 commit 4b15038

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

pbr/hooks/backwards.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,5 @@ def hook(self):
2929
packaging.append_text_list(
3030
self.config, 'tests_require',
3131
packaging.parse_requirements(
32-
packaging.TEST_REQUIREMENTS_FILES))
32+
packaging.TEST_REQUIREMENTS_FILES,
33+
strip_markers=True))

pbr/packaging.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def get_reqs_from_files(requirements_files):
8181
return []
8282

8383

84-
def parse_requirements(requirements_files=None):
84+
def parse_requirements(requirements_files=None, strip_markers=False):
8585

8686
if requirements_files is None:
8787
requirements_files = get_requirements_files()
@@ -104,7 +104,8 @@ def egg_fragment(match):
104104
# -r other-requirements.txt
105105
if line.startswith('-r'):
106106
req_file = line.partition(' ')[2]
107-
requirements += parse_requirements([req_file])
107+
requirements += parse_requirements(
108+
[req_file], strip_markers=strip_markers)
108109
continue
109110

110111
try:
@@ -130,6 +131,11 @@ def egg_fragment(match):
130131
reason = 'Index Location'
131132

132133
if line is not None:
134+
if strip_markers:
135+
semi_pos = line.find(';')
136+
if semi_pos < 0:
137+
semi_pos = None
138+
line = line[:semi_pos]
133139
requirements.append(line)
134140
else:
135141
log.info(
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ordereddict;python_version=='2.6'

0 commit comments

Comments
 (0)