classification
Title: Support resources in namespace packages
Type: Stage:
Components: Versions: Python 3.10
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: jaraco Nosy List: FFY00, barry, jaraco
Priority: normal Keywords:

Created on 2020-10-23 16:03 by jaraco, last changed 2021-01-10 21:45 by jaraco.

Messages (4)
msg379451 - (view) Author: Jason R. Coombs (jaraco) * (Python committer) Date: 2020-10-23 16:03
In [importlib_resources#68](https://github.com/python/importlib_resources/issues/68), the project identified a deficiency with respect to pkg_resources for resources in namespace packages.

The project has since merged support for these packages, slated to go out with the importlib_resources 3.2 release.

This issue is to track the incorporation of those changes into importlib.resources.
msg384770 - (view) Author: Jason R. Coombs (jaraco) * (Python committer) Date: 2021-01-10 17:47
In [this commit](https://github.com/python/importlib_resources/commit/bd20d893f11f387d285c666bc99fd2d4a7c33ef8), I've reconciled and merged the changes from importlib_resources 3.2-5.0, mainly the namespace package support (https://importlib-resources.readthedocs.io/en/latest/history.html#v5-0-0).

Applying these changes to cpython and running the tests, there appear to be two emergent failure modes:

```
cpython master $ http --follow https://github.com/python/importlib_resources/archive/cpython.zip | bsdtar --strip-components 1 -x
$ ./python.exe Tools/scripts/run_tests.py test.test_importlib 2>&1 | gist -Pc
https://gist.github.com/dde7d5a951d92726380dced21503f843
```

In my estimation, the first two failures are due to the change in the abc.ResourceReader for contents to raise FileNotFoundError.

And the latter failures are seemingly due to the built-in NamespaceLoader not having a resource reader. I suspect the fix here is to add a .get_resource_reader() method to _NamespaceLoader to return a NamespaceReader. (hint: when updating _bootstrap_external.py, you'll need to run `make regen-importlib` or `make regen-all` and recompile).

Filipe, would you be interested in exploring these issues and propose some fixes and prepare the PR that applies the changes to CPython?
msg384776 - (view) Author: Filipe LaĆ­ns (FFY00) * Date: 2021-01-10 20:13
Yes, I will look into it. Do we have a time schedule for when this should be ready, so that I can organize myself?
msg384781 - (view) Author: Jason R. Coombs (jaraco) * (Python committer) Date: 2021-01-10 21:45
Thanks!

No rush, but ideally soon enough to be merged before the beta release of Python 3.10 (2021-05-03).
History
Date User Action Args
2021-01-10 21:45:24jaracosetmessages: + msg384781
2021-01-10 20:13:17FFY00setmessages: + msg384776
2021-01-10 17:47:48jaracosetmessages: + msg384770
2020-10-23 17:09:06barrysetnosy: + barry
2020-10-23 16:10:25FFY00setnosy: + FFY00
2020-10-23 16:03:26jaracocreate