You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
I know this is a somewhat niche use-case, but I've found that
libusb_package.find_library()
does not work iflibusb_package
is in a ZIP file that is added to the Python PATH.In theory, this should work because
libusb_package.get_library_path()
usesimportlib.resources.path
to ask the resource manager to provide a filesystem path for the library. Whenlibusb_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 onfind_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 liketmpXXXXXXXlibusb-1.0.dylib
whereXXXXXXX
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 ofimportlib.resources
.The text was updated successfully, but these errors were encountered: