-
Notifications
You must be signed in to change notification settings - Fork 548
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
fix: Add libdir to library search path #2476
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because this is gated by a feature toggle, it seems to be low risk to include.
@@ -15,6 +15,12 @@ | |||
"common attributes for whl_library and pip_repository" | |||
|
|||
ATTRS = { | |||
"add_libdir_to_library_search_path": attr.bool( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NOTE: this is enabled for both, WORKSPACE and bzlmod: https://rules-python--2476.org.readthedocs.build/en/2476/api/rules_python/python/extensions/pip.html#pip.parse.add_libdir_to_library_search_path
However, bzlmod will not forward this value to underlying whl_library
instances, so extension.bzl
needs to be updated. I think we should only forward this value to whl_libraries
that are following the legacy pip
way of downloading deps or downloading an sdist.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure how to do this. Can you give me a pointer in the right direction, please?
if result.return_code != 0: | ||
fail("Failed to get LDFLAGS path: command: {}, exit code: {}, stdout: {}, stderr: {}".format(command, result.return_code, result.stdout, result.stderr)) | ||
libdir = result.stdout | ||
env["LDFLAGS"] = "-L{}".format(libdir) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we instead extend the LDFLAGS
instead of replacing the value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On line 151 we've checked to make sure that env["LDFLAGS"]
hasn't been set. We know we're not replacing anything at this point
Just want to respond to something the comment says:
It's not possible to reliably get the correct Python interpreter. This is because the repo phase doesn't know, and can't know, what the build phase is going to do (i.e. what python interpreter will be used). The basic change in this PR is somewhat an improvement, but yeah -- just wanted to point out it'll still be prone to issues. To really fix this, the sdist building needs to move into the build phase. |
I'll add some ideas about this in #2410. |
Is there anything else you'd like me to do for this PR? |
We discovered when dealing with libraries such as
psycopg2
that the wheel would attempt to link againstlibpython.a
. This fix points the linker at the correct python version being used.