Issue #179 new

namespace packages installed with --single-version-externally-managed break other packages in that namespace

Carl Meyer
created an issue

When a namespace package is installed using the --single-version-externally-managed flag, setuptools/distribute generates a special nspkg .pth file for that package to make it work as a namespace package (instead of calling pkg_resources.declare_namespace in the file).

When a namespace package using this .pth file is present in site-packages, any other packages installed in that same namespace that use the declare_namespace method will not be available for import.

The magic code in the nspkg .pth file should be fixed to make it work with packages in the same namespace using declare_namespace.

To reproduce this issue in a virtualenv, try the following:

{{{ $ virtualenv --no-site-packages --distribute testenv

this installs zope.interface as an egg, with declare_namespace in zope/

$ testenv/bin/easy_install zope.interface

$ testenv/bin/python -c "import zope.interface"

this installs zope.event using --single-version-externally-managed - pip uses this flag for all installations

$ testenv/bin/pip install zope.event

$ testenv/bin/python -c "import zope.interface" Traceback (most recent call last): File "<string>", line 1, in <module> ImportError: No module named interface


The use of easy_install and pip above is for convenience and not necessary to reproduce the bug. Downloading the sdists for zope.interface and zope.event, and installing them with "python install" (and --single-version-externally-managed for zope.event) will show the same symptom.

I can also reproduce the same issue without a virtualenv on an Ubuntu Karmic system that has zope.interface installed as a system package (which uses declare_namespace in its If I install zope.event using --single-version-externally-managed, the system zope.interface is no longer importable.