Repository navigation
depend: fix library path resolution in POSIX non-ldconfig branches - #8422
Merged
Merged
Conversation
The `resolve_library_path` helper in `PyInstaller.depend.bindepend` expects to be given a full library name; on POSIX systems, this includes `lib` prefix and `.so` suffix - typically versioned, as it appears in the soname. This means that in `_resolve_library_path_unix` codepaths that do not use `ldconfig` cache but rather search for the library in given search locations, we should not be using `_which_library` helper (which expects basename without suffix), but rather `_resolve_library_path_in_search_paths` helper (which expects full library name). However, because it was previously possible to pass a basename without suffix and because some hooks in contrib hooks repository rely on this behavior, implement support for both; if the given name has .so suffix, use `_resolve_library_path_in_search_paths` to find exact match, and if name has no suffix, use `_which_library` to find matching basename instead.
In `_resolve_library_path_unix` helper, remove the part at the end where we read the soname of the resolved library and replace the name in returned path with the soname. In most cases, this was effectively no-op, because we use this function to resolve dependencies of binaries that we analyze, and those refer to those dependencies via their sonames. However, in the unlikely case that we are trying to resolve a library with soname that differs from its true (file)name, we would need to collect it under that true (file)name; first, because whoever was referring to it expects to find it under the true (file)name, and second, becase in such case, the file with corresponding soname might not actually exist at all.
bwoodsend
approved these changes
Apr 21, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When resolving library path on POSIX systems and we do not have
ldconfigcache available (e.g., Alpine linux), use_resolve_library_path_in_search_pathsinstead of_which_library, because the former expects the name to have (versioned) .so suffix (which is usually the case), and the latter expects the name to not have suffix. For backwards compatibility reasons, keep using_which_libraryin case we are given a name without suffix.See pyinstaller/pyinstaller-hooks-contrib#724 (comment).
While we're at it, remove the replacement of resolved library's filename with its soname; because either it is the same and it is a no-op (most of the cases), or it will end up pointing to incorrect name (i.e., the other binary is referring to the library via the name we were given, so it expects to find the library under that name) which may not even exist (e.g., if the library was renamed to its current name, that differs from its soname, for whatever reason).