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

Erik Bray erik.m.bray at gmail.com
Mon Jul 6 19:08:16 CEST 2015

On Mon, Jul 6, 2015 at 12:10 PM, Donald Stufft <donald at stufft.io> wrote:
> On July 6, 2015 at 11:57:59 AM, Erik Bray (erik.m.bray at gmail.com) wrote:
>> On Sun, Jul 5, 2015 at 10:31 PM, Nick Coghlan wrote:
>> > On 6 July 2015 at 12:23, Donald Stufft 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.
>> Erik
> If you’re installing using an actual package manager like pip,
> easy_install, apt-get, yum, whatever the instructions won’t change.
> You’ll need to ``pip install foo.bar`` and the fact it depends on
> importlib2 is something the installer takes care of.

Okay--it wasn't clear to me that you were suggesting adding importlib2
as an install_requires, but that would be fine.

> You’d need to tell anyone who is using implicit namespace packages
> that they need to depend on importlib2 on Python 2, and you’d need
> to tell anyone doing a “manual” installation (e.g. they download a
> tarball from PyPI and install it manually) to get importlib2.

Got it--that's pretty reasonable I think.


More information about the Import-SIG mailing list