@@ -720,8 +720,7 @@ def add(self, dist, entry=None, insert=True, replace=False):
720
720
keys2 .append (dist .key )
721
721
self ._added_new (dist )
722
722
723
- # FIXME: 'WorkingSet.resolve' is too complex (11)
724
- def resolve (self , requirements , env = None , installer = None , # noqa: C901
723
+ def resolve (self , requirements , env = None , installer = None ,
725
724
replace_conflicting = False , extras = None ):
726
725
"""List all distributions needed to (recursively) meet `requirements`
727
726
@@ -771,33 +770,9 @@ def resolve(self, requirements, env=None, installer=None, # noqa: C901
771
770
if not req_extras .markers_pass (req , extras ):
772
771
continue
773
772
774
- dist = best .get (req .key )
775
- if dist is None :
776
- # Find the best distribution and add it to the map
777
- dist = self .by_key .get (req .key )
778
- if dist is None or (dist not in req and replace_conflicting ):
779
- ws = self
780
- if env is None :
781
- if dist is None :
782
- env = Environment (self .entries )
783
- else :
784
- # Use an empty environment and workingset to avoid
785
- # any further conflicts with the conflicting
786
- # distribution
787
- env = Environment ([])
788
- ws = WorkingSet ([])
789
- dist = best [req .key ] = env .best_match (
790
- req , ws , installer ,
791
- replace_conflicting = replace_conflicting
792
- )
793
- if dist is None :
794
- requirers = required_by .get (req , None )
795
- raise DistributionNotFound (req , requirers )
796
- to_activate .append (dist )
797
- if dist not in req :
798
- # Oops, the "best" so far conflicts with a dependency
799
- dependent_req = required_by [req ]
800
- raise VersionConflict (dist , req ).with_context (dependent_req )
773
+ dist = self ._resolve_dist (
774
+ req , best , replace_conflicting , env , installer , required_by , to_activate
775
+ )
801
776
802
777
# push the new requirements onto the stack
803
778
new_requirements = dist .requires (req .extras )[::- 1 ]
@@ -813,8 +788,38 @@ def resolve(self, requirements, env=None, installer=None, # noqa: C901
813
788
# return list of distros to activate
814
789
return to_activate
815
790
816
- def find_plugins (
817
- self , plugin_env , full_env = None , installer = None , fallback = True ):
791
+ def _resolve_dist (
792
+ self , req , best , replace_conflicting , env , installer , required_by , to_activate
793
+ ):
794
+ dist = best .get (req .key )
795
+ if dist is None :
796
+ # Find the best distribution and add it to the map
797
+ dist = self .by_key .get (req .key )
798
+ if dist is None or (dist not in req and replace_conflicting ):
799
+ ws = self
800
+ if env is None :
801
+ if dist is None :
802
+ env = Environment (self .entries )
803
+ else :
804
+ # Use an empty environment and workingset to avoid
805
+ # any further conflicts with the conflicting
806
+ # distribution
807
+ env = Environment ([])
808
+ ws = WorkingSet ([])
809
+ dist = best [req .key ] = env .best_match (
810
+ req , ws , installer , replace_conflicting = replace_conflicting
811
+ )
812
+ if dist is None :
813
+ requirers = required_by .get (req , None )
814
+ raise DistributionNotFound (req , requirers )
815
+ to_activate .append (dist )
816
+ if dist not in req :
817
+ # Oops, the "best" so far conflicts with a dependency
818
+ dependent_req = required_by [req ]
819
+ raise VersionConflict (dist , req ).with_context (dependent_req )
820
+ return dist
821
+
822
+ def find_plugins (self , plugin_env , full_env = None , installer = None , fallback = True ):
818
823
"""Find all activatable distributions in `plugin_env`
819
824
820
825
Example usage::
0 commit comments