@@ -81,8 +81,9 @@ def run_script(self, script_name: str, namespace: str) -> None:
8181
8282
8383class Distribution (BaseDistribution ):
84- def __init__ (self , dist : pkg_resources .Distribution ) -> None :
84+ def __init__ (self , dist : pkg_resources .Distribution , concrete : bool ) -> None :
8585 self ._dist = dist
86+ self ._concrete = concrete
8687 # This is populated lazily, to avoid loading metadata for all possible
8788 # distributions eagerly.
8889 self .__extra_mapping : Optional [Mapping [NormalizedName , str ]] = None
@@ -96,6 +97,10 @@ def _extra_mapping(self) -> Mapping[NormalizedName, str]:
9697
9798 return self .__extra_mapping
9899
100+ @property
101+ def is_concrete (self ) -> bool :
102+ return self ._concrete
103+
99104 @classmethod
100105 def from_directory (cls , directory : str ) -> BaseDistribution :
101106 dist_dir = directory .rstrip (os .sep )
@@ -114,7 +119,7 @@ def from_directory(cls, directory: str) -> BaseDistribution:
114119 dist_name = os .path .splitext (dist_dir_name )[0 ].split ("-" )[0 ]
115120
116121 dist = dist_cls (base_dir , project_name = dist_name , metadata = metadata )
117- return cls (dist )
122+ return cls (dist , concrete = True )
118123
119124 @classmethod
120125 def from_metadata_file_contents (
@@ -131,7 +136,7 @@ def from_metadata_file_contents(
131136 metadata = InMemoryMetadata (metadata_dict , filename ),
132137 project_name = project_name ,
133138 )
134- return cls (dist )
139+ return cls (dist , concrete = False )
135140
136141 @classmethod
137142 def from_wheel (cls , wheel : Wheel , name : str ) -> BaseDistribution :
@@ -152,7 +157,7 @@ def from_wheel(cls, wheel: Wheel, name: str) -> BaseDistribution:
152157 metadata = InMemoryMetadata (metadata_dict , wheel .location ),
153158 project_name = name ,
154159 )
155- return cls (dist )
160+ return cls (dist , concrete = wheel . is_concrete )
156161
157162 @property
158163 def location (self ) -> Optional [str ]:
@@ -264,7 +269,7 @@ def from_paths(cls, paths: Optional[List[str]]) -> BaseEnvironment:
264269
265270 def _iter_distributions (self ) -> Iterator [BaseDistribution ]:
266271 for dist in self ._ws :
267- yield Distribution (dist )
272+ yield Distribution (dist , concrete = True )
268273
269274 def _search_distribution (self , name : str ) -> Optional [BaseDistribution ]:
270275 """Find a distribution matching the ``name`` in the environment.
0 commit comments