From 449ee2e81e4d41ea76cd3b207f056b720ed6b647 Mon Sep 17 00:00:00 2001 From: Robert Taylor Date: Tue, 6 Dec 2022 01:48:49 +0000 Subject: [PATCH] Fix up rpath of binaries --- build.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/build.py b/build.py index 32a7b8b7..21d32240 100644 --- a/build.py +++ b/build.py @@ -1,9 +1,12 @@ +import io +import glob import os import platform import re import subprocess import sys import sysconfig + from distutils.version import LooseVersion from distutils.dir_util import copy_tree, remove_tree from typing import Any, Dict @@ -94,7 +97,12 @@ class ExtensionBuilder(build_ext): if os.path.exists(os.path.join(install_dir, "bin")): copy_tree(os.path.join(install_dir, "bin"), os.path.join(install_dir,"data/bin")) remove_tree(os.path.join(install_dir, "bin")) - + proc = subprocess.Popen(['file'] + glob.glob(os.path.join(install_dir,"data/bin/*")), stdout=subprocess.PIPE) + for line in io.TextIOWrapper(proc.stdout, encoding="utf-8"): + if 'ELF' in line: #TODO support other OSs + f = line.split(':')[0] + print(f"fixing up {f}") + subprocess.check_call(["patchelf", "--set-rpath", '${ORIGIN}/../../lib', f]) def build(setup_kwargs: Dict[str, Any]) -> None: cmake_modules = [