20
20
NullFinder ,
21
21
PyPy_repr ,
22
22
install ,
23
- singledispatch ,
24
23
)
25
24
from ._functools import method_cache
26
25
from ._itertools import unique_everseen
@@ -499,6 +498,11 @@ def name(self):
499
498
"""Return the 'Name' metadata for the distribution package."""
500
499
return self .metadata ['Name' ]
501
500
501
+ @property
502
+ def _normalized_name (self ):
503
+ """Return a normalized version of the name."""
504
+ return Prepared .normalize (self .name )
505
+
502
506
@property
503
507
def version (self ):
504
508
"""Return the 'Version' metadata for the distribution package."""
@@ -806,6 +810,12 @@ def read_text(self, filename):
806
810
def locate_file (self , path ):
807
811
return self ._path .parent / path
808
812
813
+ @property
814
+ def _normalized_name (self ):
815
+ stem = os .path .basename (str (self ._path ))
816
+ name , sep , rest = stem .partition ('-' )
817
+ return name
818
+
809
819
810
820
def distribution (distribution_name ):
811
821
"""Get the ``Distribution`` instance for the named package.
@@ -843,18 +853,6 @@ def version(distribution_name):
843
853
return distribution (distribution_name ).version
844
854
845
855
846
- @singledispatch
847
- def normalized_name (dist : Distribution ):
848
- return Prepared .normalize (dist .name )
849
-
850
-
851
- @normalized_name .register
852
- def _ (dist : PathDistribution ):
853
- stem = os .path .basename (str (dist ._path ))
854
- name , sep , rest = stem .partition ('-' )
855
- return name
856
-
857
-
858
856
def entry_points (** params ) -> Union [EntryPoints , SelectableGroups ]:
859
857
"""Return EntryPoint objects for all installed packages.
860
858
@@ -872,7 +870,8 @@ def entry_points(**params) -> Union[EntryPoints, SelectableGroups]:
872
870
873
871
:return: EntryPoints or SelectableGroups for all installed packages.
874
872
"""
875
- unique = functools .partial (unique_everseen , key = normalized_name )
873
+ norm_name = operator .attrgetter ('_normalized_name' )
874
+ unique = functools .partial (unique_everseen , key = norm_name )
876
875
eps = itertools .chain .from_iterable (
877
876
dist .entry_points for dist in unique (distributions ())
878
877
)
0 commit comments