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

M.-A. Lemburg mal at egenix.com
Wed Apr 22 12:59:18 CEST 2015

On 22.04.2015 12:38, Robert Collins wrote:
> On 22 April 2015 at 22:13, Christoph Schmitt <dev-mailings at gongy.de> wrote:
>> Hello again,
>> since I haven't got any replies yet I'm trying to make myself a bit more
>> precise now. I consider the behaviour described in my original posting a
>> bug. I posted to this list because the setuptools docs say "Please use the
>> distutils-sig mailing list [3] for questions and discussion about
>> Test 3)
>> DO NOT delcare namespace_packages=['coolpkg'] in setup.py of each project
>> Result: all modules can be imported
> This is correct AFAICT.
> the setuptools namespace_packages thing predates PEP-420, and because
> PEP-420 namespaces don't interoperate with .pth file based packages
> (expecially when you get into interactions between system non-PEP-420
> + virtualenv PEP-420 packages!) changing this is super hard: you'll
> guarantee to break many existing installs.
> Perhaps there should be a new keyword, but since nothing is needed to
> make things work, it seems like it would be rather redundant.

You can make use of the namespace_packages keyword argument to setup()
optional depending on which Python version is running it.

I guess that's the only way forward unless you want to break
the package for previous Python versions.

However, doing so may be hard for namespaces which are used
by a lot of packages.

Perhaps setuptools could simply ignore the keyword for
Python 3.3+ and then rely on PEP 420 to get things working
in more or less the same way:


Marc-Andre Lemburg

Professional Python Services directly from the Source  (#1, Apr 22 2015)
>>> Python Projects, Coaching and Consulting ...  http://www.egenix.com/
>>> mxODBC Plone/Zope Database Adapter ...       http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/

::::: Try our mxODBC.Connect Python Database Interface for free ! ::::::

   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
    D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
           Registered at Amtsgericht Duesseldorf: HRB 46611

More information about the Distutils-SIG mailing list