Skip to content

importlib.resources.files(__package__) api does not work  #977

@pax0r

Description

@pax0r

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 library jsonschema 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__) returns importlib._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

from importlib import resources

print('==================', resources.files(__package__))

Should shown a Traversable with files from package, istead it shows importlib._adapters.DegenerateFiles.Path

I have tried both with package mentioned in extractPackages and not.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions