in mujoco_py/builder.py [0:0]
def manually_link_libraries(mujoco_path, raw_cext_dll_path):
""" Used to fix mujoco library linking on Mac """
root, ext = os.path.splitext(raw_cext_dll_path)
final_cext_dll_path = root + '_final' + ext
# If someone else already built the final DLL, don't bother
# recreating it here, even though this should still be idempotent.
if (exists(final_cext_dll_path) and
getmtime(final_cext_dll_path) >= getmtime(raw_cext_dll_path)):
return final_cext_dll_path
tmp_final_cext_dll_path = final_cext_dll_path + '~'
shutil.copyfile(raw_cext_dll_path, tmp_final_cext_dll_path)
mj_bin_path = join(mujoco_path, 'bin')
# Fix the rpath of the generated library -- i lost the Stackoverflow
# reference here
from_mujoco_path = '@executable_path/libmujoco210.dylib'
to_mujoco_path = '%s/libmujoco210.dylib' % mj_bin_path
subprocess.check_call(['install_name_tool',
'-change',
from_mujoco_path,
to_mujoco_path,
tmp_final_cext_dll_path])
from_glfw_path = 'libglfw.3.dylib'
to_glfw_path = os.path.join(mj_bin_path, 'libglfw.3.dylib')
subprocess.check_call(['install_name_tool',
'-change',
from_glfw_path,
to_glfw_path,
tmp_final_cext_dll_path])
os.rename(tmp_final_cext_dll_path, final_cext_dll_path)
return final_cext_dll_path