@@ -81,8 +81,9 @@ def run_script(self, script_name: str, namespace: str) -> None:
81
81
82
82
83
83
class Distribution (BaseDistribution ):
84
- def __init__ (self , dist : pkg_resources .Distribution ) -> None :
84
+ def __init__ (self , dist : pkg_resources .Distribution , concrete : bool ) -> None :
85
85
self ._dist = dist
86
+ self ._concrete = concrete
86
87
# This is populated lazily, to avoid loading metadata for all possible
87
88
# distributions eagerly.
88
89
self .__extra_mapping : Optional [Mapping [NormalizedName , str ]] = None
@@ -96,6 +97,10 @@ def _extra_mapping(self) -> Mapping[NormalizedName, str]:
96
97
97
98
return self .__extra_mapping
98
99
100
+ @property
101
+ def is_concrete (self ) -> bool :
102
+ return self ._concrete
103
+
99
104
@classmethod
100
105
def from_directory (cls , directory : str ) -> BaseDistribution :
101
106
dist_dir = directory .rstrip (os .sep )
@@ -114,7 +119,7 @@ def from_directory(cls, directory: str) -> BaseDistribution:
114
119
dist_name = os .path .splitext (dist_dir_name )[0 ].split ("-" )[0 ]
115
120
116
121
dist = dist_cls (base_dir , project_name = dist_name , metadata = metadata )
117
- return cls (dist )
122
+ return cls (dist , concrete = True )
118
123
119
124
@classmethod
120
125
def from_metadata_file_contents (
@@ -131,7 +136,7 @@ def from_metadata_file_contents(
131
136
metadata = InMemoryMetadata (metadata_dict , filename ),
132
137
project_name = project_name ,
133
138
)
134
- return cls (dist )
139
+ return cls (dist , concrete = False )
135
140
136
141
@classmethod
137
142
def from_wheel (cls , wheel : Wheel , name : str ) -> BaseDistribution :
@@ -152,7 +157,7 @@ def from_wheel(cls, wheel: Wheel, name: str) -> BaseDistribution:
152
157
metadata = InMemoryMetadata (metadata_dict , wheel .location ),
153
158
project_name = name ,
154
159
)
155
- return cls (dist )
160
+ return cls (dist , concrete = wheel . is_concrete )
156
161
157
162
@property
158
163
def location (self ) -> Optional [str ]:
@@ -264,7 +269,7 @@ def from_paths(cls, paths: Optional[List[str]]) -> BaseEnvironment:
264
269
265
270
def _iter_distributions (self ) -> Iterator [BaseDistribution ]:
266
271
for dist in self ._ws :
267
- yield Distribution (dist )
272
+ yield Distribution (dist , concrete = True )
268
273
269
274
def _search_distribution (self , name : str ) -> Optional [BaseDistribution ]:
270
275
"""Find a distribution matching the ``name`` in the environment.
0 commit comments