[Distutils] Installing namespace packages with pip inserts strange modules into sys.modules

Thomas Heller theller at ctypes.org
Fri Sep 12 21:14:59 CEST 2014


Am 12.09.2014 19:15, schrieb Erik Bray:
> On Fri, Sep 12, 2014 at 8:38 AM, Thomas Heller <theller at ctypes.org> wrote:

[snip about strange .pth files installed for namespace packages]

>
> Hi Thomas,
>
> I've dealt with this issue myself extensively in the past, but it's
> been a while so I might have to give it a bit of thought before I
> comment more on detail (if no one else does first).
>
> But I don't think (unless there's something new I don't know about)
> those come directly from pip.  Rather, they are created by setuptools.

Thanks for the answer, Erik.  I've lost understanding what is done by
setuptools, disutils, wheels, pip, and whatever other software is
working when building distributions or installing them.

> The issue here is that before Python had any built-in notion of
> namespace packages, namespace packages were a feature in setuptools,
> and this was the hack, I suppose, that allowed it to work.
> Unfortunately as different versions of Python have grown different
> levels of support for namespace packages over the years, the
> setuptools hack is still the implementation of the concept that will
> work on the broadest range of Python versions (and I definitely know
> zope.interface has been using it going far back).

So it seems that it is a bug in setuptools:  It must not create or
install these pth files when installing in Python 3.3 or newer (which
implement PEP 420).

> That said, I've been meaning to try to figure out some way of
> supporting all three forms of namespace packages in a way that is
> interfering.  As I said, I've had problems with this myself :/

Thomas



More information about the Distutils-SIG mailing list