diff --git a/src/pip/_internal/req/req_install.py b/src/pip/_internal/req/req_install.py index f8957e5d994..1fe76644d3b 100644 --- a/src/pip/_internal/req/req_install.py +++ b/src/pip/_internal/req/req_install.py @@ -51,7 +51,6 @@ is_installable_dir, redact_auth_from_url, ) -from pip._internal.utils.packaging import safe_extra from pip._internal.utils.subprocess import runner_with_spinner_message from pip._internal.utils.temp_dir import TempDirectory, tempdir_kinds from pip._internal.utils.unpacking import unpack_file @@ -272,12 +271,7 @@ def match_markers(self, extras_requested: Optional[Iterable[str]] = None) -> boo extras_requested = ("",) if self.markers is not None: return any( - self.markers.evaluate({"extra": extra}) - # TODO: Remove these two variants when packaging is upgraded to - # support the marker comparison logic specified in PEP 685. - or self.markers.evaluate({"extra": safe_extra(extra)}) - or self.markers.evaluate({"extra": canonicalize_name(extra)}) - for extra in extras_requested + self.markers.evaluate({"extra": extra}) for extra in extras_requested ) else: return True diff --git a/src/pip/_internal/resolution/resolvelib/candidates.py b/src/pip/_internal/resolution/resolvelib/candidates.py index 7a139d86b5d..4c14858c81c 100644 --- a/src/pip/_internal/resolution/resolvelib/candidates.py +++ b/src/pip/_internal/resolution/resolvelib/candidates.py @@ -430,14 +430,6 @@ def __init__( ) -> None: self.base = base self.extras = frozenset(canonicalize_name(e) for e in extras) - # If any extras are requested in their non-normalized forms, keep track - # of their raw values. This is needed when we look up dependencies - # since PEP 685 has not been implemented for marker-matching, and using - # the non-normalized extra for lookup ensures the user can select a - # non-normalized extra in a package with its non-normalized form. - # TODO: Remove this attribute when packaging is upgraded to support the - # marker comparison logic specified in PEP 685. - self._unnormalized_extras = extras.difference(self.extras) def __str__(self) -> str: name, rest = str(self.base).split(" ", 1) @@ -523,7 +515,7 @@ def _calculate_valid_requested_extras(self) -> FrozenSet[str]: candidate doesn't support. Any unsupported extras are dropped, and each cause a warning to be logged here. """ - requested_extras = self.extras.union(self._unnormalized_extras) + requested_extras = self.extras valid_extras = frozenset( extra for extra in requested_extras diff --git a/tests/functional/test_install_extras.py b/tests/functional/test_install_extras.py index 8ccbcf1998d..01babeac36f 100644 --- a/tests/functional/test_install_extras.py +++ b/tests/functional/test_install_extras.py @@ -152,24 +152,14 @@ def test_install_fails_if_extra_at_end( script.scratch_path / "requirements.txt", expect_error=True, ) - assert "Extras after version" in result.stderr + assert "Invalid requirement: 'requires_simple_extra>=0.1[extra]'" in result.stderr @pytest.mark.parametrize( "specified_extra, requested_extra", [ ("Hop_hOp-hoP", "Hop_hOp-hoP"), - pytest.param( - "Hop_hOp-hoP", - "hop-hop-hop", - marks=pytest.mark.xfail( - reason=( - "matching a normalized extra request against an" - "unnormalized extra in metadata requires PEP 685 support " - "in packaging (see pypa/pip#11445)." - ), - ), - ), + ("Hop_hOp-hoP", "hop-hop-hop"), ("hop-hop-hop", "Hop_hOp-hoP"), ], )