@@ -111,13 +111,20 @@ class InvalidLicenseExpression(Exception): # type: ignore[no-redef]
111111}
112112
113113
114- def _map_to_wheel (sources : Dict [str , Dict [str , Any ]]) -> DefaultDict [str , List [Tuple [pathlib .Path , str ]]]:
114+ def _map_to_wheel (
115+ sources : Dict [str , Dict [str , Any ]],
116+ exclude : List [str ]
117+ ) -> DefaultDict [str , List [Tuple [pathlib .Path , str ]]]:
115118 """Map files to the wheel, organized by wheel installation directory."""
116119 wheel_files : DefaultDict [str , List [Tuple [pathlib .Path , str ]]] = collections .defaultdict (list )
117120 packages : Dict [str , str ] = {}
121+ excluded = re .compile ('|' .join (fnmatch .translate (x ) for x in exclude )).match if exclude else lambda x : False
118122
119123 for key , group in sources .items ():
120124 for src , target in group .items ():
125+ if excluded (target ['destination' ]):
126+ continue
127+
121128 destination = pathlib .Path (target ['destination' ])
122129 anchor = destination .parts [0 ]
123130 dst = pathlib .Path (* destination .parts [1 :])
@@ -581,6 +588,9 @@ def _string_or_path(value: Any, name: str) -> str:
581588 'args' : _table ({
582589 name : _strings for name in _MESON_ARGS_KEYS
583590 }),
591+ 'wheel' : _table ({
592+ 'exclude' : _strings ,
593+ }),
584594 })
585595
586596 table = pyproject .get ('tool' , {}).get ('meson-python' , {})
@@ -823,6 +833,9 @@ def __init__(
823833 # from the package, make sure the developers acknowledge this.
824834 self ._allow_windows_shared_libs = pyproject_config .get ('allow-windows-internal-shared-libs' , False )
825835
836+ # Files to be excluded from the wheel
837+ self ._excluded_files = pyproject_config .get ('wheel' , {}).get ('exclude' , [])
838+
826839 def _run (self , cmd : Sequence [str ]) -> None :
827840 """Invoke a subprocess."""
828841 # Flush the line to ensure that the log line with the executed
@@ -906,7 +919,7 @@ def _manifest(self) -> DefaultDict[str, List[Tuple[pathlib.Path, str]]]:
906919 sources [key ][target ] = details
907920
908921 # Map Meson installation locations to wheel paths.
909- return _map_to_wheel (sources )
922+ return _map_to_wheel (sources , self . _excluded_files )
910923
911924 @property
912925 def _meson_name (self ) -> str :
0 commit comments