Closed corranwebster closed 2 years ago
I think I'm missing something, though: it looks as though we don't have importlib_resources
mentioned in the setup.py
, so I'd expect this to fail in CI on Python versions earlier than 3.9.
Ah, I see - we're pulling in importlib_resources
through the Pyface dependency. I think we shouldn't rely on that - if we're using importlib_resources
directly in the Python code, it should be mentioned in the setup.py.
I think we need something along the lines of 'importlib-resources>=1.1.0; python_version<"3.9"',
in the install_requires
section of setup.py
.
Use
importlib.resources
inPackageResourceProtocol
instead ofpkg_resources
. Revised code should be completely compatible:file
returns a byte stream, just as thepkg_resources
-based code did. Modernized error handling based on whatimportlib.resources
raises for the cases we are interested in.Also updated tests to use
importlib.resources
, and expanded their scope to catch some other cases of note.There are other uses of
pkg_resources
in the codebase which are out of scope for this PR.