[Distutils] Bilingual namespace package conundrum

Nick Coghlan ncoghlan at gmail.com
Fri Jan 2 18:09:23 CET 2015


On 2 January 2015 at 05:19, Barry Warsaw <barry at python.org> wrote:

> - Should some other boilerplate be added to the namespace-package
> __init__.py
>   files in each portion?  Maybe the sys.hexversion guards should be
> removed so
>   that it acts the same way in both Python 2 and Python 3.
>

This was the intended solution when PEP 420 was written - we deliberately
didn't break old-style namespace packages, we just made them redundant for
code that only needs to run on 3.3+. This is much easier to learn, since it
means creating packages as subdirectories "just works", and automatically
collecting all search path subdirectories with a given name into a common
namespace by default better matches the typical behaviour of other search
path based explicit import systems.

However, implicit namespace packages aren't inherently *better* than the
old explicit ones at runtime, as the end result is the same in either case:
a module.__path__ entry that contains multiple directories. The only
difference is in whether you get there by leaving out __init__.py and
letting the 3.3+ import machinery handle it, or by doing it explicitly
yourself.

That means there's a bug to be fixed in the lazr packages - they provide an
__init__.py file, thus turning off the implicit namespace package support,
but then they use a version check to also turn off the explicit namespace
package support. If you turn off both kinds of namespace package support,
you're not going to have a namespace package at the end of it :)

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/distutils-sig/attachments/20150103/fad8e0e0/attachment.html>


More information about the Distutils-SIG mailing list