2020 NullFinder ,
2121 PyPy_repr ,
2222 install ,
23- singledispatch ,
2423)
2524from ._functools import method_cache
2625from ._itertools import unique_everseen
@@ -499,6 +498,11 @@ def name(self):
499498 """Return the 'Name' metadata for the distribution package."""
500499 return self .metadata ['Name' ]
501500
501+ @property
502+ def _normalized_name (self ):
503+ """Return a normalized version of the name."""
504+ return Prepared .normalize (self .name )
505+
502506 @property
503507 def version (self ):
504508 """Return the 'Version' metadata for the distribution package."""
@@ -806,6 +810,12 @@ def read_text(self, filename):
806810 def locate_file (self , path ):
807811 return self ._path .parent / path
808812
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+
809819
810820def distribution (distribution_name ):
811821 """Get the ``Distribution`` instance for the named package.
@@ -843,18 +853,6 @@ def version(distribution_name):
843853 return distribution (distribution_name ).version
844854
845855
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-
858856def entry_points (** params ) -> Union [EntryPoints , SelectableGroups ]:
859857 """Return EntryPoint objects for all installed packages.
860858
@@ -872,7 +870,8 @@ def entry_points(**params) -> Union[EntryPoints, SelectableGroups]:
872870
873871 :return: EntryPoints or SelectableGroups for all installed packages.
874872 """
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 )
876875 eps = itertools .chain .from_iterable (
877876 dist .entry_points for dist in unique (distributions ())
878877 )
0 commit comments