@@ -48,7 +48,7 @@ def name(self):
4848
4949
5050class EntryPoint (
51- collections .namedtuple ('EntryPointBase' , 'dist name value group' )):
51+ collections .namedtuple ('EntryPointBase' , 'name value group dist ' )):
5252 """An entry point as defined by Python packaging conventions.
5353
5454 See `the packaging docs on entry points
@@ -77,6 +77,8 @@ class EntryPoint(
7777 following the attr, and following any extras.
7878 """
7979
80+ _distribution = None
81+
8082 def load (self ):
8183 """Load the entry point from its definition. If only a module
8284 is indicated by the value, return that module. Otherwise,
@@ -102,13 +104,21 @@ def extras(self):
102104 match = self .pattern .match (self .value )
103105 return list (re .finditer (r'\w+' , match .group ('extras' ) or '' ))
104106
107+ @property
108+ def distribution (self ):
109+ if self ._distribution is None :
110+ self ._distribution = Distribution .from_name (self .dist )
111+ return self ._distribution
112+
105113 @classmethod
106114 def _from_config (cls , dist , config ):
107- return [
108- cls (dist , name , value , group )
109- for group in config .sections ()
110- for name , value in config .items (group )
111- ]
115+ eps = []
116+ for group in config .sections ():
117+ for name , value in config .items (group ):
118+ ep = cls (name , value , group , dist .name )
119+ ep ._distribution = dist
120+ eps .append (ep )
121+ return eps
112122
113123 @classmethod
114124 def _from_text (cls , dist , text ):
@@ -131,7 +141,7 @@ def __iter__(self):
131141 def __reduce__ (self ):
132142 return (
133143 self .__class__ ,
134- (self .name , self .value , self .group ),
144+ (self .name , self .value , self .group , self . dist ),
135145 )
136146
137147
0 commit comments