From 54016dbf977209ef062b4a57f07ab4cc0f8fbaa9 Mon Sep 17 00:00:00 2001 From: Daniel Hershcovich Date: Mon, 6 Nov 2017 12:00:22 +0200 Subject: [PATCH] Use @loader_path on macOS to fix loading wheels --- setup.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/setup.py b/setup.py index 6499f8ec9..241b7fd2c 100644 --- a/setup.py +++ b/setup.py @@ -292,6 +292,14 @@ def run(self): if run_process(make_cmd) != 0: raise DistutilsSetupError(" ".join(make_cmd)) + if platform.system() == "Darwin": + for lib in DATA_FILES: + new_install_name = "@loader_path/" + os.path.basename(lib) + install_name_tool_cmd = ["install_name_tool", "-id", new_install_name, lib] + log.info("Fixing install_name for %r..." % lib) + if run_process(install_name_tool_cmd) != 0: + raise DistutilsSetupError(" ".join(install_name_tool_cmd)) + # This will generally be called by the manual install elif not os.path.isdir(EIGEN3_INCLUDE_DIR): raise RuntimeError("Could not find Eigen in EIGEN3_INCLUDE_DIR={}. If doing manual install, please set the EIGEN3_INCLUDE_DIR variable with the absolute path to Eigen manually. If doing install via pip, please file an issue on github.com/clab/dynet".format(EIGEN3_INCLUDE_DIR))