Skip to content

Commit d5204dd

Browse files
committed
Move markers check into the ireq->req constructor
This makes the check apply to ALL requirement constructions, no exceptions.
1 parent 258bd79 commit d5204dd

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,14 @@ def find_candidates(self, requirements, constraint):
233233
if all(req.is_satisfied_by(c) for req in requirements)
234234
)
235235

236-
def make_requirement_from_install_req(self, ireq):
237-
# type: (InstallRequirement) -> Requirement
236+
def make_requirement_from_install_req(self, ireq, requested_extras):
237+
# type: (InstallRequirement, Iterable[str]) -> Optional[Requirement]
238+
if not ireq.match_markers(requested_extras):
239+
logger.info(
240+
"Ignoring %s: markers '%s' don't match your environment",
241+
ireq.name, ireq.markers,
242+
)
243+
return None
238244
if not ireq.link:
239245
return SpecifierRequirement(ireq)
240246
cand = self._make_candidate_from_link(
@@ -253,7 +259,7 @@ def make_requirement_from_candidate(self, candidate):
253259
def make_requirement_from_spec(self, specifier, comes_from):
254260
# type: (str, InstallRequirement) -> Requirement
255261
ireq = self._make_install_req_from_spec(specifier, comes_from)
256-
return self.make_requirement_from_install_req(ireq)
262+
return self.make_requirement_from_install_req(ireq, ())
257263

258264
def make_requirement_from_spec_matching_extras(
259265
self,
@@ -263,13 +269,7 @@ def make_requirement_from_spec_matching_extras(
263269
):
264270
# type: (...) -> Optional[Requirement]
265271
ireq = self._make_install_req_from_spec(specifier, comes_from)
266-
if not ireq.match_markers(requested_extras):
267-
logger.info(
268-
"Ignoring %s: markers '%s' don't match your environment",
269-
ireq.name, ireq.markers,
270-
)
271-
return None
272-
return self.make_requirement_from_install_req(ireq)
272+
return self.make_requirement_from_install_req(ireq, requested_extras)
273273

274274
def make_requires_python_requirement(self, specifier):
275275
# type: (Optional[SpecifierSet]) -> Optional[Requirement]

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,6 @@ def resolve(self, root_reqs, check_supported_wheels):
106106
user_requested = set() # type: Set[str]
107107
requirements = []
108108
for req in root_reqs:
109-
if not req.match_markers():
110-
continue
111109
if req.constraint:
112110
# Ensure we only accept valid constraints
113111
reject_invalid_constraint_types(req)
@@ -120,9 +118,11 @@ def resolve(self, root_reqs, check_supported_wheels):
120118
else:
121119
if req.is_direct and req.name:
122120
user_requested.add(canonicalize_name(req.name))
123-
requirements.append(
124-
self.factory.make_requirement_from_install_req(req)
121+
r = self.factory.make_requirement_from_install_req(
122+
req, requested_extras=(),
125123
)
124+
if r is not None:
125+
requirements.append(r)
126126

127127
provider = PipProvider(
128128
factory=self.factory,

0 commit comments

Comments
 (0)