-
-
Notifications
You must be signed in to change notification settings - Fork 243
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.resource #53
Comments
I would not at all be surprised if there were bugs in the behavior of the module resources APIs! There are a few issues to unravel in here. I'll definitely look at this in more detail in the days ahead unless someone beats me to it. Thank you for reporting your experience! |
Thank you for the detailed reproduction case. It looks like the behavior of The underlying problem appears to be that Lemme see about coding up a fix... |
Before, we derived is_package by the presence of a foo.bar module. Now, the canonical source of is_package is derived at build time and embedded into the binary. This allows us to properly flag __init__ files as providing packages, thus fixing #53.
The upstream CPython documentation made a reference to get_resource_loader(), which was incorrect and caused me to implement the wrong method. You can't make this up :/ This should also help with #53.
OK, things should now behave properly on the
I think this is arguably correct behavior. It is slightly different from what you get from the file-based importer because If you want to pick up Python module files as resources (it would be a legitimate feature request), we could make that a configurable setting via the packaging rules. Please file a new issue for that if wanted. |
thanks for taking a look! will open a new issue |
I'm piecing together a few parts of the documentation here so this may be a misunderstanding on my part but I'm having trouble getting the
importlib.resource
to act like I expect. Heres a trivial example I built (diff from apyoxidizer init resource
skeleton)so when I
pyoxidizer run
this I'd expect the following:instead I get
so package doesn't get set but maybe this is a known issue, but even if I specify the package in the embedded_python_run
code = "from foo import show_resources; show_resources('foo')"
above I still can't list the contents of the packagewhich is also weird because its not consistent with another time I tried this where I could successfully call
contents
but it would return an empty tuple where as I would expect it to contain__init__.py
. Apologies if I'm missing something obvious here, cool project though!The text was updated successfully, but these errors were encountered: