From 772a17c6982aec0ad58c0b69c86819fd94c3482b Mon Sep 17 00:00:00 2001 From: Dustin Ingram Date: Tue, 18 May 2021 12:22:01 -0400 Subject: [PATCH 1/3] Add failing test --- tests/functional/test_new_resolver_hashes.py | 61 ++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/tests/functional/test_new_resolver_hashes.py b/tests/functional/test_new_resolver_hashes.py index b3812011254..94462bfcf86 100644 --- a/tests/functional/test_new_resolver_hashes.py +++ b/tests/functional/test_new_resolver_hashes.py @@ -311,3 +311,64 @@ def test_new_resolver_hash_requirement_and_url_constraint_can_fail( ) in result.stderr, str(result) script.assert_not_installed("base", "other") + + +def test_new_resolver_hash_with_extras(script): + parent_with_extra_path = create_basic_wheel_for_package( + script, "parent_with_extra", "0.1.0", depends=["child[extra]"] + ) + parent_with_extra_hash = hashlib.sha256( + parent_with_extra_path.read_bytes() + ).hexdigest() + + parent_without_extra_path = create_basic_wheel_for_package( + script, "parent_without_extra", "0.1.0", depends=["child"] + ) + parent_without_extra_hash = hashlib.sha256( + parent_without_extra_path.read_bytes() + ).hexdigest() + + child_path = create_basic_wheel_for_package( + script, "child", "0.1.0", extras={"extra": ["extra"]} + ) + child_hash = hashlib.sha256(child_path.read_bytes()).hexdigest() + + # Newer release + create_basic_wheel_for_package( + script, "child", "0.2.0", extras={"extra": ["extra"]} + ) + + extra_path = create_basic_wheel_for_package(script, "extra", "0.1.0") + extra_hash = hashlib.sha256(extra_path.read_bytes()).hexdigest() + + requirements_txt = script.scratch_path / "requirements.txt" + requirements_txt.write_text( + """ + child[extra]==0.1.0 --hash=sha256:{child_hash} + parent_with_extra==0.1.0 --hash=sha256:{parent_with_extra_hash} + parent_without_extra==0.1.0 --hash=sha256:{parent_without_extra_hash} + extra==0.1.0 --hash=sha256:{extra_hash} + """.format( + child_hash=child_hash, + parent_with_extra_hash=parent_with_extra_hash, + parent_without_extra_hash=parent_without_extra_hash, + extra_hash=extra_hash, + ), + ) + + script.pip( + "install", + "--no-cache-dir", + "--no-index", + "--find-links", + script.scratch_path, + "--requirement", + requirements_txt, + ) + + script.assert_installed( + parent_with_extra="0.1.0", + parent_without_extra="0.1.0", + child="0.1.0", + extra="0.1.0", + ) From 316a75b2a56e5d8c9f0c10feb735312714f0a248 Mon Sep 17 00:00:00 2001 From: Dustin Ingram Date: Tue, 18 May 2021 12:47:26 -0400 Subject: [PATCH 2/3] Add NEWS entry so tests will actually run --- news/9644.bugfix.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 news/9644.bugfix.rst diff --git a/news/9644.bugfix.rst b/news/9644.bugfix.rst new file mode 100644 index 00000000000..d423dc26bb8 --- /dev/null +++ b/news/9644.bugfix.rst @@ -0,0 +1 @@ +Fix an issue where pip did not consider dependencies with and without extras to be equal From 06cd80332869423631a07ef88e83343fba36af7d Mon Sep 17 00:00:00 2001 From: Dustin Ingram Date: Thu, 2 Dec 2021 16:38:29 -0500 Subject: [PATCH 3/3] Add type annotations --- tests/functional/test_new_resolver_hashes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/functional/test_new_resolver_hashes.py b/tests/functional/test_new_resolver_hashes.py index 94462bfcf86..39c1d012c65 100644 --- a/tests/functional/test_new_resolver_hashes.py +++ b/tests/functional/test_new_resolver_hashes.py @@ -313,7 +313,7 @@ def test_new_resolver_hash_requirement_and_url_constraint_can_fail( script.assert_not_installed("base", "other") -def test_new_resolver_hash_with_extras(script): +def test_new_resolver_hash_with_extras(script: PipTestEnvironment) -> None: parent_with_extra_path = create_basic_wheel_for_package( script, "parent_with_extra", "0.1.0", depends=["child[extra]"] )