From 8f762e257b9321a750b4efaa2cfa4d7cba68a48f Mon Sep 17 00:00:00 2001 From: Keith Smiley Date: Thu, 26 Sep 2024 14:58:22 -0700 Subject: [PATCH] Remove absolute path from libpython.dylib (#2256) Previously this set the install name of the binary, which is put into any binaries that link this, as an absolute path that is user specific. Instead this can be fetched relatively, and bazel will automatically handle adding the correct rpaths for this. --- python/private/python_repository.bzl | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/python/private/python_repository.bzl b/python/private/python_repository.bzl index 2710299b39..e44bdd151d 100644 --- a/python/private/python_repository.bzl +++ b/python/private/python_repository.bzl @@ -143,12 +143,11 @@ def _python_repository_impl(rctx): # dyld lookup errors. To fix, set the full path to the dylib as # it appears in the Bazel workspace as its LC_ID_DYLIB using # the `install_name_tool` bundled with macOS. - dylib = "lib/libpython{}.dylib".format(python_short_version) - full_dylib_path = rctx.path(dylib) + dylib = "libpython{}.dylib".format(python_short_version) repo_utils.execute_checked( rctx, op = "python_repository.FixUpDyldIdPath", - arguments = [repo_utils.which_checked(rctx, "install_name_tool"), "-id", full_dylib_path, dylib], + arguments = [repo_utils.which_checked(rctx, "install_name_tool"), "-id", "@rpath/{}".format(dylib), "lib/{}".format(dylib)], logger = logger, )