[Import-SIG] Bundling importlib2 with Python 2.7.x?

Erik Bray erik.m.bray at gmail.com
Mon Jul 6 17:57:57 CEST 2015

On Sun, Jul 5, 2015 at 10:31 PM, Nick Coghlan <ncoghlan at gmail.com> wrote:
> On 6 July 2015 at 12:23, Donald Stufft <donald at stufft.io> wrote:
>> On July 5, 2015 at 10:18:07 PM, Nick Coghlan (ncoghlan at gmail.com) wrote:
>>> What do folks think of the idea of proposing bundling importlib2 with
>>> Python 2.7.x (via pip), such that issues like
>>> https://bitbucket.org/pypa/setuptools/issue/250/ can be addressed by
>>> telling people to enable the Python 3 style import system?
>>> That is, Python 2 would still use the legacy import system by default,
>>> but Python 3 style imports would just be an "import importlib2;
>>> importlib2.install_import_hooks()" away?
>>> The main risk I see with the idea is projects deciding to install
>>> those hooks as a side effect of their own import.
>> If you’re already installing a third party module, isn’t installing
>> a second third party module a pretty small amount of additional work?
>> IOW, bundling pip made sense because of the bootstrapping problems,
>> but once you have pip, directing people to depend on importlib2 isn’t
>> very hard if they’re already installing hypotheticalthingthatwoulduseit?
> Aye, a docs-only approach could work, and would definitely be easier
> to maintain. It may just be a matter of pushing in that direction on
> the PyPA side of things, by considering "requires importlib2 on Python
> 2.7" to be a reasonable requirement for getting some kinds of
> operations to work smoothly.

I'm not exactly sure I follow--the types of operations we're talking
about involve installation of packages, and I can't go telling users
"you have to install importlib2 in order for installation of these
packages to not hose up your system" when they're installing
distributions that have namespace packages.

I think that this issue affects more than just `./setup.py develop` /
`pip install --editable`.  It also affects installation of namespace
packages with or without --single-version-externally-managed (that is
as eggs or not).  Having importlib2 to natively support new-style
namespace packages would be a boon, and pulling it in along with pip
seems like it would be straightforward to support.

Alternatively I would argue to just include it with setuptools.


More information about the Import-SIG mailing list