-
Notifications
You must be signed in to change notification settings - Fork 550
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -139,11 +139,28 @@ def _parse_optional_attrs(rctx, args, extra_pip_args = None): | |
if rctx.attr.enable_implicit_namespace_pkgs: | ||
args.append("--enable_implicit_namespace_pkgs") | ||
|
||
env = {} | ||
if rctx.attr.environment != None: | ||
args += [ | ||
"--environment", | ||
json.encode(struct(arg = rctx.attr.environment)), | ||
] | ||
for key, value in rctx.attr.environment.items(): | ||
env[key] = value | ||
|
||
# This is super hacky, but working out something nice is tricky. | ||
# This is in particular needed for psycopg2 which attempts to link libpython.a, | ||
# in order to point the linker at the correct python intepreter. | ||
if rctx.attr.add_libdir_to_library_search_path: | ||
if "LDFLAGS" in env: | ||
fail("Can't set both environment LDFLAGS and add_libdir_to_library_search_path") | ||
command = [pypi_repo_utils.resolve_python_interpreter(rctx), "-c", "import sys ; sys.stdout.write('{}/lib'.format(sys.exec_prefix))"] | ||
result = rctx.execute(command) | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. Should we instead extend the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On line 151 we've checked to make sure that |
||
|
||
args += [ | ||
"--environment", | ||
json.encode(struct(arg = env)), | ||
] | ||
|
||
return args | ||
|
||
|
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, soextension.bzl
needs to be updated. I think we should only forward this value towhl_libraries
that are following the legacypip
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?