@@ -125,6 +125,10 @@ def _compile_patterns(patterns: List[str]) -> Callable[[str], bool]:
125125class _Entry (typing .NamedTuple ):
126126 dst : pathlib .Path
127127 src : str
128+ # Meson support only one install_rpath entry per target. Use a
129+ # list to store install RPATH to be able to add append more
130+ # entries when needed.
131+ install_rpath : List [str ] = []
128132
129133
130134def _map_to_wheel (
@@ -183,7 +187,8 @@ def _map_to_wheel(
183187 filedst = dst / relpath
184188 wheel_files [path ].append (_Entry (filedst , filesrc ))
185189 else :
186- wheel_files [path ].append (_Entry (dst , src ))
190+ install_rpath = target .get ('install_rpath' )
191+ wheel_files [path ].append (_Entry (dst , src , [install_rpath ] if install_rpath else []))
187192
188193 return wheel_files
189194
@@ -449,13 +454,15 @@ def _stable_abi(self) -> Optional[str]:
449454 return 'abi3.abi3t' if abi3t else 'abi3'
450455 return None
451456
452- def _install_path (self , wheel_file : mesonpy ._wheelfile .WheelFile , origin : Path , destination : pathlib .Path ) -> None :
457+ def _install_path (self , wheel_file : mesonpy ._wheelfile .WheelFile , origin : Path , destination : pathlib .Path ,
458+ install_rpath : List [str ]) -> None :
453459 """Add a file to the wheel."""
454460
455- if self ._has_internal_libs :
456- if _is_native (origin ):
457- libspath = os .path .relpath (self ._libs_dir , destination .parent )
458- mesonpy ._rpath .fix_rpath (origin , libspath )
461+ if self ._has_internal_libs and _is_native (origin ):
462+ libspath = os .path .relpath (self ._libs_dir , destination .parent )
463+ mesonpy ._rpath .fix_rpath (origin , install_rpath , libspath )
464+ elif install_rpath :
465+ mesonpy ._rpath .fix_rpath (origin , install_rpath , None )
459466
460467 try :
461468 wheel_file .write (origin , destination .as_posix ())
@@ -499,7 +506,7 @@ def build(self, directory: Path) -> pathlib.Path:
499506 root = 'purelib' if self ._pure else 'platlib'
500507
501508 for path , entries in self ._manifest .items ():
502- for dst , src in entries :
509+ for dst , src , rpath in entries :
503510 counter .update (src )
504511
505512 if path == root :
@@ -510,7 +517,7 @@ def build(self, directory: Path) -> pathlib.Path:
510517 else :
511518 dst = pathlib .Path (self ._data_dir , path , dst )
512519
513- self ._install_path (whl , src , dst )
520+ self ._install_path (whl , src , dst , rpath )
514521
515522 return wheel_file
516523
0 commit comments