[Distutils] [issue113] namespace packages installed with --single-version-externally-managed break other packages in that namespace

Carl Meyer setuptools at bugs.python.org
Fri Aug 27 19:57:18 CEST 2010


New submission from Carl Meyer <carl at oddbird.net>:

When a namespace package is installed using the --single-version-externally-managed flag, setuptools 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 init.py 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 testenv

# this installs zope.interface as an egg, with declare_namespace in zope/__init__.py
$ 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 setup.py 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 init.py). If I install zope.event using --single-version-externally-managed, the system zope.interface is no longer importable.

----------
messages: 537
nosy: carljm
priority: bug
status: unread
title: namespace packages installed with --single-version-externally-managed break other packages in that namespace

_______________________________________________
Setuptools tracker <setuptools at bugs.python.org>
<http://bugs.python.org/setuptools/issue113>
_______________________________________________


More information about the Distutils-SIG mailing list