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
importlib.resources.files(__package__) api does not work #977
Comments
It looks like implementing the new
Thanks for the report. We'll fix this in the next version of Chaquopy. |
Since the new |
I've managed to patch 3rd party lib by myself but I can't wait for fix in Chaquopy ;) I've seen that in Python < 3.9 it uses https://pypi.org/project/importlib-resources/ for this task but I haven't tested it on Android. |
To make it easy to remove the old API, we should reimplement it in terms of the new one, just as importlib itself now does in Python 3.12 (see implementation of importlib.resources.abc.TraversableResources). There's a probable error here:
But as of Python 3.12, |
Describe your issue
For some reason I can't get the
importlib.resources.files(__package__)
to work. In my case this is used by external libraryjsonschema
but I was able to reproduce this in my own code as well. By documentation this should return some Traversable with files in given module.jsonschema
library is using it to load some.json
files inside the package directory.In Chaquopy each call to
importlib.resources.files(__package__)
returnsimportlib._adapters.DegenerateFiles.Path
which means it cannot read files from package dir.According to this comment: #745 (comment) it should work
Chaquopy version
id 'com.chaquo.python' version '14.0.2' apply false
Devices or emulators where the issue happens
Tested on emulator only, but I think it does not matter
Relevant parts of your code
Should shown a
Traversable
with files from package, istead it showsimportlib._adapters.DegenerateFiles.Path
I have tried both with package mentioned in
extractPackages
and not.The text was updated successfully, but these errors were encountered: