-
-
Notifications
You must be signed in to change notification settings - Fork 227
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
Cannot read Python modules with importlib.resources using PyOxidizer #207
Comments
The
The reason this fails in PyOxidizer is because PyOxidizer currently flags each embedded entity as just a single type. e.g. a thing is a source module, a bytecode module, or a resource entry. It can't be multiple. We should probably expose embedded module sources and bytecode as resources as well to maintain compatibility with CPython. This would address this particular problem. But maintaining parity for listing contents is something I'd prefer to hold off implementing until the Python maintainers give a canonical answer as to how all of this is supposed to work. |
Whether relative paths become a blessed alternative to recurse into subdirectories I think is unlikely to affect the output of def list_resources(package: str) -> Iterable[Tuple[str, str]]:
"Recursively list package resources."
from importlib.resources import contents as list_contents, is_resource
resources = True
subpackages = False
contents: DefaultDict[bool, List[str]] = bucketise(list_contents(package),
partial(is_resource, package))
for resource in contents[resources]:
yield (package, resource)
for subpackage in contents[subpackages]:
yield from list_resources(package + '.' + subpackage) But should it? |
FYI |
I sat down to implement the new API today. Unfortunately, it involved a lot of head scratching and I failed to make meaningful progress. I'll have to wait for the Python developers to address my feedback on the new API design. https://gitlab.com/python-devs/importlib_resources/-/issues/90 |
I've made a lot of improvements to resources handling in the current development release. Notable changes include:
Unless there are some bugs lingering, I'm quite confident that the new code/features is good enough to handle most cases where it was failing before. Please open new issues tracking specific feature requests or bugs. |
I might be missing something, but I don't see how I might be able to access Python source files through |
No, PyOxidizer's importer doesn't yet support accessing source and bytecode data via the resources API. This issue was tracking a few different things and I got side-tracked by all the various correctness issues around path resolution that I forgot to address the initial feature request of exposing source and bytecode data. Could someone please file a new issue requesting those features? It might be worthwhile to file separate issues for source from bytecode, as the latter is a bit more scope to implement, since PyOxidizer currently doesn't embed the 16 byte |
This is the only way to get this game to build with pyoxidizer and as a python module. See: indygreg/PyOxidizer#207
This is the only way to get this game to build with pyoxidizer and as a python module. See: indygreg/PyOxidizer#207
This is the only way to get this game to build with pyoxidizer and as a python module. See: indygreg/PyOxidizer#207
CPython:
PyOxidizer:
PyOxidizer also handles
is_resource
differently:Compare with the default reader:
The text was updated successfully, but these errors were encountered: