1616 from mesonpy ._compat import Iterable , Path
1717
1818
19- if sys .platform == 'linux' :
20-
21- def _get_rpath (filepath : Path ) -> List [str ]:
22- r = subprocess .run (['patchelf' , '--print-rpath' , os .fspath (filepath )], capture_output = True , text = True )
23- return r .stdout .strip ().split (':' )
24-
25- def _set_rpath (filepath : Path , rpath : Iterable [str ]) -> None :
26- subprocess .run (['patchelf' ,'--set-rpath' , ':' .join (rpath ), os .fspath (filepath )], check = True )
19+ if sys .platform == 'win32' or sys .platform == 'cygwin' :
2720
2821 def fix_rpath (filepath : Path , libs_relative_path : str ) -> None :
29- old_rpath = _get_rpath (filepath )
30- new_rpath = []
31- for path in old_rpath :
32- if path .startswith ('$ORIGIN/' ):
33- path = '$ORIGIN/' + libs_relative_path
34- new_rpath .append (path )
35- if new_rpath != old_rpath :
36- _set_rpath (filepath , new_rpath )
37-
22+ raise NotImplementedError (f'Bundling libraries in wheel is not supported on { sys .platform } ' )
3823
3924elif sys .platform == 'darwin' :
4025
@@ -59,6 +44,21 @@ def fix_rpath(filepath: Path, libs_relative_path: str) -> None:
5944 _replace_rpath (filepath , path , '@loader_path/' + libs_relative_path )
6045
6146else :
47+ # Assume that any other platform uses ELF binaries.
48+
49+ def _get_rpath (filepath : Path ) -> List [str ]:
50+ r = subprocess .run (['patchelf' , '--print-rpath' , os .fspath (filepath )], capture_output = True , text = True )
51+ return r .stdout .strip ().split (':' )
52+
53+ def _set_rpath (filepath : Path , rpath : Iterable [str ]) -> None :
54+ subprocess .run (['patchelf' ,'--set-rpath' , ':' .join (rpath ), os .fspath (filepath )], check = True )
6255
6356 def fix_rpath (filepath : Path , libs_relative_path : str ) -> None :
64- raise NotImplementedError (f'Bundling libraries in wheel is not supported on { sys .platform } ' )
57+ old_rpath = _get_rpath (filepath )
58+ new_rpath = []
59+ for path in old_rpath :
60+ if path .startswith ('$ORIGIN/' ):
61+ path = '$ORIGIN/' + libs_relative_path
62+ new_rpath .append (path )
63+ if new_rpath != old_rpath :
64+ _set_rpath (filepath , new_rpath )
0 commit comments