[Distutils] Proper handling of PEP420 namespace packages with setuptools and pip

Donald Stufft donald at stufft.io
Thu Apr 23 02:31:52 CEST 2015


> On Apr 22, 2015, at 5:25 PM, Chris Barker <chris.barker at noaa.gov> wrote:
> 
> A note from the peanut gallery:
> 
> I  like the idea of namepace packages, but every time I've tried to use them, I've been stymied -- maybe this PEP will solve that, but...
> 
> First -  the issues:
> 
> - It somehow seems like a lot of work, details to get right, and more-than-one-way-to-do-it. But maybe that's all pre- PEP 420
> 
> - Last time I tried, I couldn't get them to work with "setup.py develop"
> 
> But at the core of this -- Why does it have to be so hard? It seems very simple to me -- what am I missing?
> 
> What are namespace packages? To me, they are a package that serves no other purpose than to provide a single namespace in which to put other packages. This makes a lot of sense if you have a bunch of related packages where users may only require one, or a couple, but not all. And you want to be able to maintain them, and version control them independently.
> 
> But it seem to get this, all we need is:
> 
> 1) A directory with the top-level name
> 
> 2) It has an (empty)  __init__.py (so it is a python package)
> 
> 3) It has other directories in it -- each of these are regular old python packages -- the ONLY difference is that they are installed under that name
> 
> That's it. Done. Now all we need is a way to install these things -- well that's easy, each sub-package installs itself just like it would, maybe overwriting the top level directory name and the __init__.py, if another sub-package has already installed it. But that's OK, because the name is by definition the same, and the __init__ is empty.
> 
> This seems SO SIMPLE. No declaring things all over the place, no dynamic path manipulation, nothing unusual at all, except the ability to install a module into a dir without clobbering what might already be in that dir.
> 
> What am I missing?


Prior to PEP 420 you needed the dynamic path stuff because sometimes your namespace package is split across multiple locations on sys.path. Relying on the filesystem as you mentioned only works if you install every single namespace package into the same directory.

PEP 420 more or less solves all of the problems with namespace packages, other than it’s a Python 3 only feature so most people aren’t going to be willing to depend on it.

---
Donald Stufft
PGP: 7C6B 7C5D 5E2B 6356 A926 F04F 6E3C BCE9 3372 DCFA

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/distutils-sig/attachments/20150422/208fb633/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://mail.python.org/pipermail/distutils-sig/attachments/20150422/208fb633/attachment.sig>


More information about the Distutils-SIG mailing list