Consider migrating to importlib_resources for finding data file in packages
- Dominant language
- Python
- Stars
- 14
- Forks
- 7
- PR merge metrics
- No merged PRs in 30d
Description
As we move to consolidating all `entry_point` related code into `ComponentRegistry.load_extensions`, there are some places, most notably in `iotile-build` where we also explicitly load data files using `pkg_resources.resource_filename`. This method does not have a direct, non-hacky analog that we could embed into `ComponentRegistry` and is just as slow as the rest of `pkg_resources`, potentially negating the speed benefits of #472, which the `load_extensions` refactor is designed to allow.
So, we need an alternative to `pkg_resources.resource_filename` and it looks like `importlib_resources` is the best alternative. It is a backport of stdlib functionality introduced in Python 3.7 to 2.7 and 3.4+:
https://importlib-resources.readthedocs.io/en/latest/using.html
It has analog methods for most of what we need from `pkg_resources` in terms of file loading.
Contributor guide
Assessment
This issue has not been assessed yet.