From bc4193b183bb58c56cb3b46c04b763aebba09c54 Mon Sep 17 00:00:00 2001 From: Ben Nemec Date: Tue, 28 Aug 2018 21:39:48 +0000 Subject: Ignore --find-links in requirements file We already skip things like --index-url, but --find-links can also be present and also shouldn't be included in install_requires. This also fixes some issues with the existing unit test for this filtering. Change-Id: Ie8eca8c19e955d52722feaa71d5843ccd74b0da0 Closes-Bug: 1716808 --- pbr/packaging.py | 3 ++- pbr/tests/test_packaging.py | 10 ++++++---- releasenotes/notes/ignore-find-links-07cf54f465aa33a6.yaml | 6 ++++++ 3 files changed, 14 insertions(+), 5 deletions(-) create mode 100644 releasenotes/notes/ignore-find-links-07cf54f465aa33a6.yaml diff --git a/pbr/packaging.py b/pbr/packaging.py index bb0ec6b..c1d729f 100644 --- a/pbr/packaging.py +++ b/pbr/packaging.py @@ -116,7 +116,8 @@ def parse_requirements(requirements_files=None, strip_markers=False): continue # Ignore index URL lines - if re.match(r'^\s*(-i|--index-url|--extra-index-url).*', line): + if re.match(r'^\s*(-i|--index-url|--extra-index-url|--find-links).*', + line): continue # Handle nested requirements files such as: diff --git a/pbr/tests/test_packaging.py b/pbr/tests/test_packaging.py index 9bd91ae..50922d2 100644 --- a/pbr/tests/test_packaging.py +++ b/pbr/tests/test_packaging.py @@ -532,11 +532,13 @@ class ParseRequirementsTest(base.BaseTestCase): tempdir = tempfile.mkdtemp() requirements = os.path.join(tempdir, 'requirements.txt') with open(requirements, 'w') as f: - f.write('-i https://myindex.local') - f.write(' --index-url https://myindex.local') - f.write(' --extra-index-url https://myindex.local') + f.write('-i https://myindex.local\n') + f.write(' --index-url https://myindex.local\n') + f.write(' --extra-index-url https://myindex.local\n') + f.write('--find-links https://myindex.local\n') + f.write('arequirement>=1.0\n') result = packaging.parse_requirements([requirements]) - self.assertEqual([], result) + self.assertEqual(['arequirement>=1.0'], result) def test_nested_requirements(self): tempdir = tempfile.mkdtemp() diff --git a/releasenotes/notes/ignore-find-links-07cf54f465aa33a6.yaml b/releasenotes/notes/ignore-find-links-07cf54f465aa33a6.yaml new file mode 100644 index 0000000..0d10a26 --- /dev/null +++ b/releasenotes/notes/ignore-find-links-07cf54f465aa33a6.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + PBR now ignores ``--find-links`` in requirements files. This option is not + a valid ``install_requires`` entry for setuptools and thus breaks + PBR-based installs. -- cgit v1.2.1