[Distutils] PEP 376, Uninstallation and interoperability

PJ Eby pje at telecommunity.com
Mon Feb 18 07:25:30 CET 2013

On Sat, Feb 16, 2013 at 7:40 AM, Vinay Sajip <vinay_sajip at yahoo.co.uk> wrote:
> Nick Coghlan <ncoghlan <at> gmail.com> writes:
>> That suggests to me that a separate "clean" command in the PEP 376
>> aware tools would be a better choice, where it looks for directories
>> that are either empty or contain only __pycache__ subdirectories. Such
> That seems to suggest that you can't be sure of doing a clean uninstallation, and
> the user has to run both uninstall and clean - is that what you meant? It seems
> a shame to have to do that.
> With my suggestion about keeping a list of shared locations around, then
> namespace package directories could be kept in such a list. When uninstalling,
> all the subpackages added in the particular distribution being uninstalled would
> be removed, but the namespace package directory itself wouldn't be, as a shared
> location.
> Are there any downsides to keeping such a list of shared locations, and using
> it in the way I've described?

Yes - it's unnecessary for library directories (e.g. stuff under
site-packages).  You may safely remove any empty subdirectory of the
directories containing the .dist-info, that is a parent of any of the
files belonging to the distribution you are uninstalling.  (In
addition, you may optionally detect and offer to remove extraneous
files by cross-checking against all other .dist-info records for that
same directory -- a file not listed anywhere is an orphan.)

Scripts, man pages, and all that are a separate issue.  I would think
it would *generally* be safe to use the "remove any empty subdirectory
of the relevant base directory which is a parent of a file you
uninstalled" rule, but orphan detection would not be possible, and
there's some possibility that you could delete an empty directory
erroneously.  For that purpose, some sort of site-local configuration
might be useful, especially if it tracks local conventions like being
able to say that e.g., /usr/share/doc/$DISTNAME-$VERSION is the base
directory for a package's docs and that it should be considered
distribution-owned (and therefore removed if empty, and considered to
have orphans if any non-project files are in it).

More information about the Distutils-SIG mailing list