[Import-SIG] Proposed design for importlib.resources()

Nick Coghlan ncoghlan at gmail.com
Wed Nov 25 04:36:15 EST 2015


On 25 November 2015 at 10:28, Brett Cannon <brett at python.org> wrote:
> If we make it e.g.,  __loader__.resources().read_bytes(path) then I may be
> more amenable to creating a importlib.resources module with the bastardized
> pkg_resources API. Going to have to think about it, though.

I think a compatibility shim on PyPI actually makes more sense, as
then you can put the conditional pkg_resources dependency *in the
shim*. That is, projects that switch would add a runtime dependency on
"pkg_resources_compat" (or whatever name you choose) and then do "
import pkg_resources_compat as pkg_resources"

On Python 3.5 and earlier versions, pkg_resources_compat would depend
on setuptools, and just re-export the pkg_resources APIs.
On Python 3.6 and later, it would instead be a compatibility wrapper
around the updated import machinery

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia


More information about the Import-SIG mailing list