@@ -128,7 +128,7 @@ def _init_colors() -> Dict[str, str]:
128
128
129
129
130
130
def _map_to_wheel (sources : Dict [str , Dict [str , Any ]]) -> DefaultDict [str , List [Tuple [pathlib .Path , str ]]]:
131
- """Map files to the wheel, organized by wheel installation directrory ."""
131
+ """Map files to the wheel, organized by wheel installation directory ."""
132
132
wheel_files : DefaultDict [str , List [Tuple [pathlib .Path , str ]]] = collections .defaultdict (list )
133
133
packages : Dict [str , str ] = {}
134
134
@@ -259,26 +259,22 @@ def __init__(
259
259
metadata : Metadata ,
260
260
source_dir : pathlib .Path ,
261
261
build_dir : pathlib .Path ,
262
- sources : Dict [str , Dict [ str , Any ]],
262
+ manifest : Dict [str , List [ Tuple [ pathlib . Path , str ] ]],
263
263
) -> None :
264
264
self ._project = project
265
265
self ._metadata = metadata
266
266
self ._source_dir = source_dir
267
267
self ._build_dir = build_dir
268
- self ._sources = sources
269
-
270
- @cached_property
271
- def _wheel_files (self ) -> DefaultDict [str , List [Tuple [pathlib .Path , str ]]]:
272
- return _map_to_wheel (self ._sources )
268
+ self ._manifest = manifest
273
269
274
270
@property
275
271
def _has_internal_libs (self ) -> bool :
276
- return bool (self ._wheel_files .get ('mesonpy-libs' ))
272
+ return bool (self ._manifest .get ('mesonpy-libs' ))
277
273
278
274
@property
279
275
def _has_extension_modules (self ) -> bool :
280
276
# Assume that all code installed in {platlib} is Python ABI dependent.
281
- return bool (self ._wheel_files .get ('platlib' ))
277
+ return bool (self ._manifest .get ('platlib' ))
282
278
283
279
@property
284
280
def normalized_name (self ) -> str :
@@ -322,9 +318,9 @@ def is_pure(self) -> bool:
322
318
# non-pure, but I think it's better that we evaluate use-cases as they
323
319
# arise and make sure allowing the user to override this is indeed the
324
320
# best option for the use-case.
325
- if self ._wheel_files ['platlib' ]:
321
+ if self ._manifest ['platlib' ]:
326
322
return False
327
- for _ , file in self ._wheel_files ['scripts' ]:
323
+ for _ , file in self ._manifest ['scripts' ]:
328
324
if self ._is_native (file ):
329
325
return False
330
326
return True
@@ -368,7 +364,7 @@ def _stable_abi(self) -> Optional[str]:
368
364
# in {platlib} that look like extension modules, and raise
369
365
# an exception if any of them has a Python version
370
366
# specific extension filename suffix ABI tag.
371
- for path , _ in self ._wheel_files ['platlib' ]:
367
+ for path , _ in self ._manifest ['platlib' ]:
372
368
match = _EXTENSION_SUFFIX_REGEX .match (path .name )
373
369
if match :
374
370
abi = match .group ('abi' )
@@ -382,8 +378,8 @@ def _stable_abi(self) -> Optional[str]:
382
378
@property
383
379
def top_level_modules (self ) -> Collection [str ]:
384
380
modules = set ()
385
- for type_ in self ._wheel_files :
386
- for path , _ in self ._wheel_files [type_ ]:
381
+ for type_ in self ._manifest :
382
+ for path , _ in self ._manifest [type_ ]:
387
383
name , dot , ext = path .parts [0 ].partition ('.' )
388
384
if dot :
389
385
# module
@@ -461,11 +457,11 @@ def build(self, directory: Path) -> pathlib.Path:
461
457
with mesonpy ._wheelfile .WheelFile (wheel_file , 'w' ) as whl :
462
458
self ._wheel_write_metadata (whl )
463
459
464
- with mesonpy ._util .cli_counter (sum (len (x ) for x in self ._wheel_files .values ())) as counter :
460
+ with mesonpy ._util .cli_counter (sum (len (x ) for x in self ._manifest .values ())) as counter :
465
461
466
462
root = 'purelib' if self .is_pure else 'platlib'
467
463
468
- for path , entries in self ._wheel_files .items ():
464
+ for path , entries in self ._manifest .items ():
469
465
for dst , src in entries :
470
466
counter .update (src )
471
467
@@ -761,7 +757,7 @@ def _wheel_builder(self) -> _WheelBuilder:
761
757
self ._metadata ,
762
758
self ._source_dir ,
763
759
self ._build_dir ,
764
- self ._install_plan ,
760
+ self ._manifest ,
765
761
)
766
762
767
763
@property
@@ -791,31 +787,33 @@ def _info(self, name: str) -> Any:
791
787
return json .loads (info .read_text ())
792
788
793
789
@property
794
- def _install_plan (self ) -> Dict [str , Dict [str , Dict [str , str ]]]:
795
- """Meson install_plan metadata."""
790
+ def _manifest (self ) -> DefaultDict [str , List [Tuple [pathlib .Path , str ]]]:
791
+ """The files to be added to the wheel, organized by wheel path."""
792
+
793
+ # Obtain the list of files Meson would install.
796
794
install_plan = self ._info ('intro-install_plan' )
797
795
798
- # parse install args to extract --tags and --skip-subprojects
796
+ # Parse the 'meson install' args to extract --tags and --skip-subprojects
799
797
parser = argparse .ArgumentParser ()
800
798
parser .add_argument ('--tags' )
801
799
parser .add_argument ('--skip-subprojects' , nargs = '?' , const = '*' , default = '' )
802
800
args , _ = parser .parse_known_args (self ._meson_args ['install' ])
803
801
install_tags = {t .strip () for t in args .tags .split (',' )} if args .tags else None
804
802
skip_subprojects = {p for p in (p .strip () for p in args .skip_subprojects .split (',' )) if p }
805
803
806
- manifest : DefaultDict [str , Dict [str , Dict [str , str ]]] = collections .defaultdict (dict )
807
-
808
- # filter install_plan accordingly
804
+ # Filter the install plan accordingly.
805
+ sources : DefaultDict [str , Dict [str , Dict [str , str ]]] = collections .defaultdict (dict )
809
806
for key , targets in install_plan .items ():
810
807
for target , details in targets .items ():
811
808
if install_tags is not None and details ['tag' ] not in install_tags :
812
809
continue
813
810
subproject = details .get ('subproject' )
814
811
if subproject is not None and (subproject in skip_subprojects or '*' in skip_subprojects ):
815
812
continue
816
- manifest [key ][target ] = details
813
+ sources [key ][target ] = details
817
814
818
- return manifest
815
+ # Map Meson installation locations to wheel paths.
816
+ return _map_to_wheel (sources )
819
817
820
818
@property
821
819
def _meson_name (self ) -> str :
0 commit comments