@@ -404,8 +404,24 @@ def _report_requires_python_error(
404
404
)
405
405
return UnsupportedPythonVersion (message )
406
406
407
- def get_installation_error (self , e ):
408
- # type: (ResolutionImpossible) -> InstallationError
407
+ def _report_single_requirement_conflict (self , req , parent ):
408
+ # type: (Requirement, Candidate) -> DistributionNotFound
409
+ if parent is None :
410
+ req_disp = str (req )
411
+ else :
412
+ req_disp = f"{ req } (from { parent .name } )"
413
+ logger .critical (
414
+ "Could not find a version that satisfies the requirement %s" ,
415
+ req_disp ,
416
+ )
417
+ return DistributionNotFound (f"No matching distribution found for { req } " )
418
+
419
+ def get_installation_error (
420
+ self ,
421
+ e , # type: ResolutionImpossible
422
+ constraints , # type: Dict[str, Constraint]
423
+ ):
424
+ # type: (...) -> InstallationError
409
425
410
426
assert e .causes , "Installation error reported with no cause"
411
427
@@ -425,15 +441,8 @@ def get_installation_error(self, e):
425
441
# satisfied. We just report that case.
426
442
if len (e .causes ) == 1 :
427
443
req , parent = e .causes [0 ]
428
- if parent is None :
429
- req_disp = str (req )
430
- else :
431
- req_disp = f"{ req } (from { parent .name } )"
432
- logger .critical (
433
- "Could not find a version that satisfies the requirement %s" ,
434
- req_disp ,
435
- )
436
- return DistributionNotFound (f"No matching distribution found for { req } " )
444
+ if req .name not in constraints :
445
+ return self ._report_single_requirement_conflict (req , parent )
437
446
438
447
# OK, we now have a list of requirements that can't all be
439
448
# satisfied at once.
@@ -475,13 +484,20 @@ def describe_trigger(parent):
475
484
)
476
485
logger .critical (msg )
477
486
msg = "\n The conflict is caused by:"
487
+
488
+ relevant_constraints = set ()
478
489
for req , parent in e .causes :
490
+ if req .name in constraints :
491
+ relevant_constraints .add (req .name )
479
492
msg = msg + "\n "
480
493
if parent :
481
494
msg = msg + "{} {} depends on " .format (parent .name , parent .version )
482
495
else :
483
496
msg = msg + "The user requested "
484
497
msg = msg + req .format_for_error ()
498
+ for key in relevant_constraints :
499
+ spec = constraints [key ].specifier
500
+ msg += f"\n The user requested (constraint) { key } { spec } "
485
501
486
502
msg = (
487
503
msg
0 commit comments