File tree 2 files changed +26
-3
lines changed
2 files changed +26
-3
lines changed Original file line number Diff line number Diff line change @@ -1015,6 +1015,15 @@ def version(distribution_name):
1015
1015
return distribution (distribution_name ).version
1016
1016
1017
1017
1018
+ _unique = functools .partial (
1019
+ unique_everseen ,
1020
+ key = operator .attrgetter ('_normalized_name' ),
1021
+ )
1022
+ """
1023
+ Wrapper for ``distributions`` to return unique distributions by name.
1024
+ """
1025
+
1026
+
1018
1027
def entry_points (** params ) -> Union [EntryPoints , SelectableGroups ]:
1019
1028
"""Return EntryPoint objects for all installed packages.
1020
1029
@@ -1032,10 +1041,8 @@ def entry_points(**params) -> Union[EntryPoints, SelectableGroups]:
1032
1041
1033
1042
:return: EntryPoints or SelectableGroups for all installed packages.
1034
1043
"""
1035
- norm_name = operator .attrgetter ('_normalized_name' )
1036
- unique = functools .partial (unique_everseen , key = norm_name )
1037
1044
eps = itertools .chain .from_iterable (
1038
- dist .entry_points for dist in unique (distributions ())
1045
+ dist .entry_points for dist in _unique (distributions ())
1039
1046
)
1040
1047
return SelectableGroups .load (eps ).select (** params )
1041
1048
Original file line number Diff line number Diff line change 13
13
EntryPoint ,
14
14
MetadataPathFinder ,
15
15
PackageNotFoundError ,
16
+ _unique ,
16
17
distributions ,
17
18
entry_points ,
18
19
metadata ,
@@ -105,6 +106,21 @@ def test_dist_name_found_as_any_case(self):
105
106
assert version (pkg_name .lower ()) == '1.0'
106
107
assert version (pkg_name .upper ()) == '1.0'
107
108
109
+ def test_unique_distributions (self ):
110
+ """
111
+ Two distributions varying only by non-normalized name on
112
+ the file system should resolve as the same.
113
+ """
114
+ fixtures .build_files (self .make_pkg ('abc' ), self .site_dir )
115
+ before = list (_unique (distributions ()))
116
+
117
+ alt_site_dir = self .fixtures .enter_context (fixtures .tempdir ())
118
+ self .fixtures .enter_context (self .add_sys_path (alt_site_dir ))
119
+ fixtures .build_files (self .make_pkg ('ABC' ), alt_site_dir )
120
+ after = list (_unique (distributions ()))
121
+
122
+ assert len (after ) == len (before )
123
+
108
124
109
125
class NonASCIITests (fixtures .OnSysPath , fixtures .SiteDir , unittest .TestCase ):
110
126
@staticmethod
You can’t perform that action at this time.
0 commit comments