Skip to content

Commit 50247de

Browse files
authored
Merge pull request #8291 from pradyunsg/direct-url-with-extras
New Resolver: Add support for direct URLs with extras
2 parents 6aa9b89 + 50c9ea2 commit 50247de

File tree

3 files changed

+13
-14
lines changed

3 files changed

+13
-14
lines changed

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

+6-9
Original file line numberDiff line numberDiff line change
@@ -347,8 +347,8 @@ class ExtrasCandidate(Candidate):
347347
to treat it as a separate node in the dependency graph.
348348
2. When we're getting the candidate's dependencies,
349349
a) We specify that we want the extra dependencies as well.
350-
b) We add a dependency on the base candidate (matching the name and
351-
version). See below for why this is needed.
350+
b) We add a dependency on the base candidate.
351+
See below for why this is needed.
352352
3. We return None for the underlying InstallRequirement, as the base
353353
candidate will provide it, and we don't want to end up with duplicates.
354354
@@ -417,20 +417,17 @@ def iter_dependencies(self):
417417
extra
418418
)
419419

420+
# Add a dependency on the exact base
421+
# (See note 2b in the class docstring)
422+
yield factory.make_requirement_from_candidate(self.base)
423+
420424
for r in self.base.dist.requires(valid_extras):
421425
requirement = factory.make_requirement_from_spec_matching_extras(
422426
str(r), self.base._ireq, valid_extras,
423427
)
424428
if requirement:
425429
yield requirement
426430

427-
# Add a dependency on the exact base.
428-
# (See note 2b in the class docstring)
429-
# FIXME: This does not work if the base candidate is specified by
430-
# link, e.g. "pip install .[dev]" will fail.
431-
spec = "{}=={}".format(self.base.name, self.base.version)
432-
yield factory.make_requirement_from_spec(spec, self.base._ireq)
433-
434431
def get_install_requirement(self):
435432
# type: () -> Optional[InstallRequirement]
436433
# We don't return anything here, because we always

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

+6-2
Original file line numberDiff line numberDiff line change
@@ -180,12 +180,16 @@ def make_requirement_from_install_req(self, ireq):
180180
# TODO: Get name and version from ireq, if possible?
181181
# Specifically, this might be needed in "name @ URL"
182182
# syntax - need to check where that syntax is handled.
183-
cand = self._make_candidate_from_link(
183+
candidate = self._make_candidate_from_link(
184184
ireq.link, extras=set(ireq.extras), parent=ireq,
185185
)
186-
return ExplicitRequirement(cand)
186+
return self.make_requirement_from_candidate(candidate)
187187
return SpecifierRequirement(ireq, factory=self)
188188

189+
def make_requirement_from_candidate(self, candidate):
190+
# type: (Candidate) -> ExplicitRequirement
191+
return ExplicitRequirement(candidate)
192+
189193
def make_requirement_from_spec(self, specifier, comes_from):
190194
# type: (str, InstallRequirement) -> Requirement
191195
ireq = self._make_install_req_from_spec(specifier, comes_from)

tests/functional/test_new_resolver.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -825,9 +825,7 @@ def _wheel_from_index(script, name, version, requires, extras):
825825
@pytest.mark.parametrize(
826826
"pkg_builder",
827827
[
828-
pytest.param(
829-
_local_with_setup, marks=pytest.mark.xfail(strict=True),
830-
),
828+
_local_with_setup,
831829
_direct_wheel,
832830
_wheel_from_index,
833831
],

0 commit comments

Comments
 (0)