From f286fb8bdd55d5583456df439159d172f896d072 Mon Sep 17 00:00:00 2001 From: Pradyun Gedam Date: Wed, 28 Mar 2018 13:44:21 +0530 Subject: [PATCH] pip check should care about the markers --- src/pip/_internal/operations/check.py | 4 ++++ tests/functional/test_check.py | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/pip/_internal/operations/check.py b/src/pip/_internal/operations/check.py index e5bc96e35..e882ff4c1 100644 --- a/src/pip/_internal/operations/check.py +++ b/src/pip/_internal/operations/check.py @@ -54,6 +54,10 @@ def check_package_set(package_set): # Check if it's missing if name not in package_set: + missed = True + if req.marker is not None: + missed = req.marker.evaluate() + if missed: missing_deps.add((name, req)) continue diff --git a/tests/functional/test_check.py b/tests/functional/test_check.py index d52bea990..ade108067 100644 --- a/tests/functional/test_check.py +++ b/tests/functional/test_check.py @@ -172,3 +172,24 @@ def test_check_complicated_name_clean(script): ) assert matches_expected_lines(result.stdout, expected_lines) assert result.returncode == 0 + + +def test_check_considers_conditional_reqs(script): + package_a_path = create_test_package_with_setup( + script, + name='package_A', version='1.0', + install_requires=[ + "Dependency-B>=1.0; python_version != '2.7'", + "Dependency-B>=2.0; python_version == '2.7'", + ], + ) + + result = script.pip('install', '--no-index', package_a_path, '--no-deps') + assert "Successfully installed package-A-1.0" in result.stdout, str(result) + + result = script.pip('check', expect_error=True) + expected_lines = ( + "package-a 1.0 requires dependency-b, which is not installed.", + ) + assert matches_expected_lines(result.stdout, expected_lines) + assert result.returncode == 1 -- GitLab