|
16 | 16 | from mesonpy._compat import Iterable, Path
|
17 | 17 |
|
18 | 18 |
|
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': |
27 | 20 |
|
28 | 21 | 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}') |
38 | 23 |
|
39 | 24 | elif sys.platform == 'darwin':
|
40 | 25 |
|
@@ -85,6 +70,21 @@ def fix_rpath(filepath: Path, libs_relative_path: str) -> None:
|
85 | 70 | _set_rpath(filepath, new_rpath)
|
86 | 71 |
|
87 | 72 | else:
|
| 73 | + # Assume that any other platform uses ELF binaries. |
| 74 | + |
| 75 | + def _get_rpath(filepath: Path) -> List[str]: |
| 76 | + r = subprocess.run(['patchelf', '--print-rpath', os.fspath(filepath)], capture_output=True, text=True) |
| 77 | + return r.stdout.strip().split(':') |
| 78 | + |
| 79 | + def _set_rpath(filepath: Path, rpath: Iterable[str]) -> None: |
| 80 | + subprocess.run(['patchelf','--set-rpath', ':'.join(rpath), os.fspath(filepath)], check=True) |
88 | 81 |
|
89 | 82 | def fix_rpath(filepath: Path, libs_relative_path: str) -> None:
|
90 |
| - raise NotImplementedError(f'Bundling libraries in wheel is not supported on {sys.platform}') |
| 83 | + old_rpath = _get_rpath(filepath) |
| 84 | + new_rpath = [] |
| 85 | + for path in old_rpath: |
| 86 | + if path.startswith('$ORIGIN/'): |
| 87 | + path = '$ORIGIN/' + libs_relative_path |
| 88 | + new_rpath.append(path) |
| 89 | + if new_rpath != old_rpath: |
| 90 | + _set_rpath(filepath, new_rpath) |
0 commit comments