Skip to content

Commit 3af04b6

Browse files
committed
Remove various extras normalization workarounds
1 parent cab0a56 commit 3af04b6

File tree

3 files changed

+4
-28
lines changed

3 files changed

+4
-28
lines changed

src/pip/_internal/req/req_install.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
is_installable_dir,
5252
redact_auth_from_url,
5353
)
54-
from pip._internal.utils.packaging import safe_extra
5554
from pip._internal.utils.subprocess import runner_with_spinner_message
5655
from pip._internal.utils.temp_dir import TempDirectory, tempdir_kinds
5756
from pip._internal.utils.unpacking import unpack_file
@@ -272,12 +271,7 @@ def match_markers(self, extras_requested: Optional[Iterable[str]] = None) -> boo
272271
extras_requested = ("",)
273272
if self.markers is not None:
274273
return any(
275-
self.markers.evaluate({"extra": extra})
276-
# TODO: Remove these two variants when packaging is upgraded to
277-
# support the marker comparison logic specified in PEP 685.
278-
or self.markers.evaluate({"extra": safe_extra(extra)})
279-
or self.markers.evaluate({"extra": canonicalize_name(extra)})
280-
for extra in extras_requested
274+
self.markers.evaluate({"extra": extra}) for extra in extras_requested
281275
)
282276
else:
283277
return True

src/pip/_internal/resolution/resolvelib/candidates.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -430,14 +430,6 @@ def __init__(
430430
) -> None:
431431
self.base = base
432432
self.extras = frozenset(canonicalize_name(e) for e in extras)
433-
# If any extras are requested in their non-normalized forms, keep track
434-
# of their raw values. This is needed when we look up dependencies
435-
# since PEP 685 has not been implemented for marker-matching, and using
436-
# the non-normalized extra for lookup ensures the user can select a
437-
# non-normalized extra in a package with its non-normalized form.
438-
# TODO: Remove this attribute when packaging is upgraded to support the
439-
# marker comparison logic specified in PEP 685.
440-
self._unnormalized_extras = extras.difference(self.extras)
441433

442434
def __str__(self) -> str:
443435
name, rest = str(self.base).split(" ", 1)
@@ -523,7 +515,7 @@ def _calculate_valid_requested_extras(self) -> FrozenSet[str]:
523515
candidate doesn't support. Any unsupported extras are dropped, and each
524516
cause a warning to be logged here.
525517
"""
526-
requested_extras = self.extras.union(self._unnormalized_extras)
518+
requested_extras = self.extras
527519
valid_extras = frozenset(
528520
extra
529521
for extra in requested_extras

tests/functional/test_install_extras.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -152,24 +152,14 @@ def test_install_fails_if_extra_at_end(
152152
script.scratch_path / "requirements.txt",
153153
expect_error=True,
154154
)
155-
assert "Extras after version" in result.stderr
155+
assert "Invalid requirement: 'requires_simple_extra>=0.1[extra]'" in result.stderr
156156

157157

158158
@pytest.mark.parametrize(
159159
"specified_extra, requested_extra",
160160
[
161161
("Hop_hOp-hoP", "Hop_hOp-hoP"),
162-
pytest.param(
163-
"Hop_hOp-hoP",
164-
"hop-hop-hop",
165-
marks=pytest.mark.xfail(
166-
reason=(
167-
"matching a normalized extra request against an"
168-
"unnormalized extra in metadata requires PEP 685 support "
169-
"in packaging (see pypa/pip#11445)."
170-
),
171-
),
172-
),
162+
("Hop_hOp-hoP", "hop-hop-hop"),
173163
("hop-hop-hop", "Hop_hOp-hoP"),
174164
],
175165
)

0 commit comments

Comments
 (0)