find_library() does not work if libusb_package is in a ZIP file
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 40
- Forks
- 19
- PR merge metrics
- No merged PRs in 30d
Description
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.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading libusb_package.find_library() and get_library_path(), then reproduce the case with the package loaded from a ZIP on Python's import path. Confirm that the extracted temporary library is accepted while normal library discovery continues to work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 52/100