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

find_library() does not work if libusb_package is in a ZIP file #9

Open
ntamas opened this issue Apr 7, 2022 · 0 comments
Open

find_library() does not work if libusb_package is in a ZIP file #9

ntamas opened this issue Apr 7, 2022 · 0 comments

Comments

@ntamas
Copy link

ntamas commented Apr 7, 2022

I know this is a somewhat niche use-case, but I've found that libusb_package.find_library() does not work if libusb_package is in a ZIP file that is added to the Python PATH.

In theory, this should work because libusb_package.get_library_path() uses importlib.resources.path to ask the resource manager to provide a filesystem path for the library. When libusb_package is in a ZIP file, importlib.resources extracts the library to a temporary file and returns the path to the temporary file. This is fine, but later on find_library() checks the name of the returned file and accepts the library only if its name starts with the name of the library that the user expected -- and this is not true any more if the library is extracted to a temporary file. For instance, on macOS, the name of the temporary file is something like tmpXXXXXXXlibusb-1.0.dylib where XXXXXXX is a random part.

Would you accept a PR that relaxes the condtions in find_library() such that it accepts the extracted file if the library name appears anywhere in the filename? This is still not a foolproof check because there are absolutely no guarantees about the name of the returned temporary file, but it would at least solve the problem with the current Python implementation of importlib.resources.

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

No branches or pull requests

1 participant