Skip to content

Remove absolute path from libpython.dylib #2256

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions python/private/python_repository.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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)],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How exactly does Bazel set the rpath? Does it add every location with cc_imports in it to the rpath list?

In any case, this is better than my previous solution, which ultimately just traded a non-existing absolute lib path against an existing one.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How exactly does Bazel set the rpath? Does it add every location with cc_imports in it to the rpath list?

Yea something like this, in general it's an implementation detail but as long as it's correctly surfaced through the CC rules it's up to bazel to handle.

In any case, this is better than my previous solution, which ultimately just traded a non-existing absolute lib path against an existing one.

Yea I guess since the path was invalid before, it's unlikely that folks were able to depend on it. But importantly the first non-existant path was stable, and this absolute one means teams won't get cache hits if they are using it.

logger = logger,
)

Expand Down