enthought / envisage

Envisage is a Python-based framework for building applications whose functionalities can be extended by adding "plug-ins".
http://docs.enthought.com/envisage/
Other
82 stars 26 forks source link

Update package resource protocol to use importlib.resources #466

Closed corranwebster closed 2 years ago

corranwebster commented 2 years ago

Use importlib.resources in PackageResourceProtocol instead of pkg_resources. Revised code should be completely compatible: file returns a byte stream, just as the pkg_resources-based code did. Modernized error handling based on what importlib.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.

mdickinson commented 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.

mdickinson commented 2 years ago

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.