-
-
Notifications
You must be signed in to change notification settings - Fork 45
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
NotADirectoryError: MultiplexedPath only supports directories
#287
Comments
update: Ok, so it seems importlib.resources.files (or importlib_metadata.files) works fine when package is pip installed, but fails when it's zipimported, with the folder structure as is. But adding an |
This issue seems related to a similar issue reported in CPython. In this case, however, you legitimately have a namespace package and thus probably want it multiplexed. It's similar in that the use of That said, it's not obvious to me there's not a bug here. I think there very well may be. Let me see if I can repro the issue. |
Yes, I can
Breaking in to debug, I can see that
That is, it does exist, but not as a PosixPath. I think the issue is visible in that listing - namely the casting of I changed the invocation to simply |
Looking through the test suite, there's no coverage of namespace packages in zip files, so I'll address that first (and expect it to capture the failed expectation). |
…ns to Traversable objects. Closes #287.
…ns to Traversable objects. Closes #287.
…ns to Traversable objects. Closes #287.
…ns to Traversable objects. Closes #287.
….0.1 to version 6.1.0 Jason R. Coombs (19): Add API docs. Closes #245. Pin against sphinx 7.2.5 as workaround for sphinx/sphinx-doc#11662. Closes jaraco/skeleton#88. Allow GITHUB_* settings to pass through to tests. Remove spinner disablement. If it's not already fixed upstream, that's where it should be fixed. Clean up 'color' environment variables. Add diff-cover check to Github Actions CI. Closes jaraco/skeleton#90. Add descriptions to the tox environments. Closes jaraco/skeleton#91. Add FORCE_COLOR to the TOX_OVERRIDE for GHA. Requires tox 4.11.1. Closes jaraco/skeleton#89. Replace static zip fixtures with dynamically generated zip fixtures built from the same modules as found on the file system. Separate 'disk' concern of namespace tests. Prefer ``pass_env`` in tox config. Preferred failure mode for tox-dev/tox#3127 and closes jaraco/skeleton#92. In zip namespace fixtures, explicitly generate the directory entries implied by children. Workaround for python/cpython#59110. Add xfail tests for namespace packages in a zip, capturing missed expectation reported in python/importlib_resources#287. Update MultiplexedPath to expect Traversable and add a compatibility shim with deprecation warning. Update tests for MultiplexedPath to pass traversables, addressing some deprecation warnings. Update changelog When constructing a MultiplexedPath, resolve submodule_search_locations to Traversable objects. Closes python/importlib_resources#287. Honor backslashes in inner paths as found in submodule_search_locations. Finalize
Hi,
I'm trying to get a resource file from a namespace zipped package with
importlib_resources
. I know it works, at least in a specific use case of mine, but in another setting I can't make it work anymore, whatever I try :'(I have this kind of folder structure in my pkg, which I zip with, e.g.
zip -r -0 namespace.zip namespace/
, for testing purposes:I work with Spark and in the case the namespace package is pip installed and imported, I'm able to use
importlib-metadata
andzipfile
to zip the pkgs I need and send them to Spark workers withaddPyFile
(which essentially copies the zip wherever on the nodes and adds it to sys.path, sozipimport
mechanism is involved).But in another use case, I need to send the zip directly, still relying on adding the path to
sys.path
and later usingimportlib_resources.files
(orimportlib.resources.files
for that matter, which gives the same error) to retrieve sayconfig1.json
.In the first case I can do `imr.files('namespace.data.configs').joinpath('config1.json') without problem, but in the second case I cannot and always get this error:
I've still no clue what's going wrong. I can get
imr.files("namespace.pkg1")
however, as before, but I don't know why I can't get tonamespace/data
.setup: py310, importlib_resources 6.0.1
Thanks !
The text was updated successfully, but these errors were encountered: