Skip to content

Commit

Permalink
#3049 Refactor casadi lib rpaths
Browse files Browse the repository at this point in the history
  • Loading branch information
agriyakhetarpal committed Sep 11, 2023
1 parent e7dd32a commit 8388ac6
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions scripts/fix_casadi_rpath_mac.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
Removes the rpath from libcasadi.dylib in the casadi python install
and uses a fixed path
Removes the rpath from libcasadi.dylib and libcasadi.3.7.dylib in the casadi python
install and uses a fixed path
Used when building the wheels for macos
"""
Expand All @@ -15,25 +15,39 @@
libcppabi_name = "libc++abi.dylib"
libcasadi_name = "libcasadi.dylib"
libcasadi_37_name = "libcasadi.3.7.dylib"
install_name_tool_args = [
install_name_tool_args_for_libcasadi_name = [
"-change",
os.path.join("@rpath", libcpp_name),
os.path.join(casadi_dir, libcpp_name),
os.path.join(casadi_dir, libcasadi_name),
]
install_name_tool_args_for_libcasadi_37_name = [
"-change",
os.path.join("@rpath", libcpp_name),
os.path.join(casadi_dir, libcpp_name),
os.path.join(casadi_dir, libcasadi_37_name),
]
subprocess.run(["otool"] + ["-L", os.path.join(casadi_dir, libcasadi_name)])
print(" ".join(["install_name_tool"] + install_name_tool_args))
subprocess.run(["install_name_tool"] + install_name_tool_args)

print(" ".join(["install_name_tool"] + install_name_tool_args_for_libcasadi_name))
subprocess.run(["install_name_tool"] + install_name_tool_args_for_libcasadi_name)

print(" ".join(["install_name_tool"] + install_name_tool_args_for_libcasadi_37_name))
subprocess.run(["install_name_tool"] + install_name_tool_args_for_libcasadi_37_name)

subprocess.run(["otool"] + ["-L", os.path.join(casadi_dir, libcasadi_name)])

install_name_tool_args = [
"-change",
os.path.join("@rpath", libcppabi_name),
os.path.join(casadi_dir, libcppabi_name),
os.path.join(casadi_dir, libcpp_name),
]
subprocess.run(["otool"] + ["-L", os.path.join(casadi_dir, libcpp_name)])

print(" ".join(["install_name_tool"] + install_name_tool_args))
subprocess.run(["install_name_tool"] + install_name_tool_args)

subprocess.run(["otool"] + ["-L", os.path.join(casadi_dir, libcpp_name)])

# Copy libcasadi.3.7.dylib and libc++.1.0.dylib to LD_LIBRARY_PATH ($HOME/.local/lib)
Expand Down

0 comments on commit 8388ac6

Please sign in to comment.