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

Location of bundled libraries is non-deterministic #192

Closed
mwoehlke-kitware opened this issue Nov 24, 2023 · 2 comments · Fixed by #194
Closed

Location of bundled libraries is non-deterministic #192

mwoehlke-kitware opened this issue Nov 24, 2023 · 2 comments · Fixed by #194
Labels

Comments

@mwoehlke-kitware
Copy link

Describe the bug
delocate-wheel picks a non-deterministic directory for bundled .dylibs.

To Reproduce
This is reproducible by building the macOS wheels of Drake. I'm not sure what would be required for a simpler test case.

Expected behavior
Bundled .dylibs should always be in the same directory.

Platform (please complete the following information):

  • OS version: [e.g. macOS 12, macOS 10.15]
  • Delocate version: [e.g. 0.10.0]

Additional context
This behavior is caused by wheels for which tools.find_package_dirs returns multiple entries of the form {'a', 'ba'}, where a is the package name. For example, when delocating the Drake wheel, the package directories are .../drake and .../pydrake. Because _decide_dylib_bundle_directory uses directory.endswith(package_name) to select a result, and because the order of the items in the set is non-deterministic (at least with respect to their final component), the result of _decide_dylib_bundle_directory is non-deterministic.

A correct implementation is to split the final path component from directory and compare it to package_name, e.g. directory.rsplit('/', 1)[-1] == package_name.

@HexDecimal
Copy link
Collaborator

I would prefer pathlib to .rsplit, especially since string handling methods caused this problem in the first place.

Relevant code to change:

package_dirs = find_package_dirs(wheel_dir)
for directory in package_dirs:
if directory.endswith(package_name):
# Prefer using the directory with the same name as the package.
return pjoin(directory, lib_sdir)

@mwoehlke-kitware
Copy link
Author

There are a number of ways this could be "correctly" implemented; I just gave as an example the one that was quickest/shortest to write.

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

Successfully merging a pull request may close this issue.

2 participants