Skip to content

pkg_util leaves broken packages on uninstall #314

@jaraco

Description

@jaraco

I've just encountered another issue related to pkg_util-based namespace packages on pre-PEP 420 packages. Uninstallation of one package in a namespace breaks the package for all other in that namespace. Consider:

$ virtualenv --python python2.7 env
Running virtualenv with interpreter /usr/local/bin/python2.7
New python executable in /Users/jaraco/env/bin/python2.7
Also creating executable in /Users/jaraco/env/bin/python
Installing setuptools, pip, wheel...done.
$ env/bin/pip install -q backports.unittest_mock backports.datetime_timestamp
$ env/bin/pip uninstall -y backports.datetime_timestamp                  
Uninstalling backports.datetime-timestamp-1.1:
  Successfully uninstalled backports.datetime-timestamp-1.1
$ env/bin/python -c "import backports.unittest_mock"                      
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named backports.unittest_mock

The issue occurs because the uninstallation step causes the removal of the now necessary __init__.py module for the backports package. The issue doesn't occur on late releases of Python 3.3 because the package gets implicitly converted to a PEP 420 namespace package (during the uninstallation step), which in some ways is worse, because the backports package will vacillate between PEP-420 and pkg_util-managed depending on whether the last operation was an install or uninstall.

In some sense, this issue is an issue with pip and the way it installs packages all into the same location, rather than keeping distribution packages somehow separated the way eggs sought to do, but it's also a symptom of using only pkg_util for namespace package management, an issue that was addressed by setuptools' installation of the -nspkg.pth files.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions