Skip to content
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

feature: allow specifying additional library paths (fixes: #373) #374

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jlaine
Copy link

@jlaine jlaine commented Feb 23, 2022

Add new --add-path option to auditwheel repair to search for libraries
in additional directories. This avoid having to manipulate
LD_LIBRARY_PATH in the calling process (e.g. cibuildwheel), as this can
have undesirable side-effects.

The name of the option is chosen to match the one provided by
delvewheel on Windows.

fixes #373

@jlaine
Copy link
Author

jlaine commented Feb 23, 2022

NOTE: this option would actually also make sense for the lddtree and show commands but I was unsure how to add it to multiple commands without duplicating code.

@codecov
Copy link

codecov bot commented Feb 23, 2022

Codecov Report

Merging #374 (ae0aae5) into main (bc524d6) will decrease coverage by 0.35%.
The diff coverage is 28.57%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #374      +/-   ##
==========================================
- Coverage   92.36%   92.01%   -0.36%     
==========================================
  Files          23       23              
  Lines        1258     1265       +7     
  Branches      307      309       +2     
==========================================
+ Hits         1162     1164       +2     
- Misses         55       59       +4     
- Partials       41       42       +1     
Impacted Files Coverage Δ
src/auditwheel/main_repair.py 84.28% <28.57%> (-6.20%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f3c7691...ae0aae5. Read the comment docs.

@jlaine
Copy link
Author

jlaine commented Feb 23, 2022

@mayeut note that all of the tests in tests/integration/test_manylinux.py which currently manipulate LD_LIBRARY_PATH could be rewritten to use this new option. Would you like me to do this?

Add new --add-path option to auditwheel repair to search for libraries
in additional directories. This avoid having to manipulate
LD_LIBRARY_PATH in the calling process (e.g. cibuildwheel), as this can
have undesirable side-effects.

The name of the option is chosen to match the one provided by
`delvewheel` on Windows.
Copy link
Member

@mayeut mayeut left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution.

NOTE: this option would actually also make sense for the lddtree and show commands but I was unsure how to add it to multiple commands without duplicating code.

This is definitely needed. Probably requires a small helper file to setup the correct parser argument to all three & fix up LD_LIBRARY_PATH in a single place.

Note that all of the tests in tests/integration/test_manylinux.py which currently manipulate LD_LIBRARY_PATH could be rewritten to use this new option. Would you like me to do this?

For part of them yes, It'd be good to keep some of them using the environment variable directly in order to ensure this won't get broken in the future.

Comment on lines +96 to +101
p.add_argument(
"--add-path",
dest="PATHS",
default="",
help=f"Additional path(s) to search for libraries, {os.pathsep!r}-delimited",
)
Copy link
Member

Choose a reason for hiding this comment

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

I understand that you wanted to use the same name as delvewheel which seems like a good thing however, it feels more like -L/--library-path or -rpath-link to mimic a bit more what feels like ld would be doing. I'd probably go with --library-path, allowed to be specified multiple times. Unfortunately, -L is already used for something else...

I'd be in favor of having the option specified multiple times with a single path each time rather than a single string option.

@lkollar, any thoughts on the name ? (Once it gets in, we won't be able to change it without breaking users).

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree that passing multiple paths is nicer with --library-path specified multiple times. However, overall I don't fully understand why this feature is necessary. What this PR does is functionally equivalent with running LD_LIBRARY_PATH=<path> audithweel repair. Doing this in cibuildwheel would need something like CIBW_REPAIR_WHEEL_COMMAND='LD_LIBRARY_PATH=<path> audithweel repair -w {dest_dir} {wheel}'. Maybe I'm missing something?

Copy link
Author

Choose a reason for hiding this comment

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

@lkollar you're not missing anything, this is accurate, it can indeed be achieved by manipulating LD_LIBRARY_PATH. I hadn't realized that the "repair wheel command" was invoked in a shell, making it possible to alter environment variables. Now I'm not sure whether we actually want this option..

Choose a reason for hiding this comment

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

@jlaine I guess too many people do not realize that LD_LIBRARY_PATH is a solution for ValueError: Cannot repair wheel, because required library "xxx.so" could not be located, and that's exactly the reason why this PR is needed.

Unfortunately, -L is already used for something else...

@mayeut and I can't say I didn't try it, because there was no other option.

--add-path is good for parity with delvewheel https://github.com/adang1345/delvewheel#additional-options

I would also add the pointer to it the error message, so that instead of plain ValueError there is a hint what to do next.

Choose a reason for hiding this comment

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

Actually the proper fix is to propagate the option values to lddtree here. It already parses LD_LIBRARY_PATH, so no need to handle that.

elftree = lddtree(fn)

Choose a reason for hiding this comment

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

Appears it is not that easy. If ldpaths to lddtree() is supplied, then LD_LIBRARY_PATH won't be parsed. Don't know if it is a good thing or not. Also my knowledge is not enough to understand the dict params.

ldpaths
dict containing library paths to search; should have the keys:
conf, env, interp. If not supplied, the function ``load_ld_paths``
will be called.

@zoj613
Copy link

zoj613 commented May 23, 2023

What the progress on this? I have ran into this issue repairing wheels that were built linking to libraries installed bia conda.

@mwtoews
Copy link
Contributor

mwtoews commented Jul 24, 2023

Would this PR resolve limitation #1? For instance, I'd like to create a package using pure ctypes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Handling additional library directories from cibuidwheel
6 participants