[Distutils] PEP 376, Uninstallation and interoperability

Nick Coghlan ncoghlan at gmail.com
Sat Feb 16 13:08:57 CET 2013


On Sat, Feb 16, 2013 at 9:49 PM, Paul Moore <p.f.moore at gmail.com> wrote:
> On 16 February 2013 09:58, Chris Jerdonek <chris.jerdonek at gmail.com> wrote:
>> On Sat, Feb 16, 2013 at 12:42 AM, Vinay Sajip <vinay_sajip at yahoo.co.uk> wrote:
>>> Another question arises - what is to be done when directories, which are
>>> meant to be deleted during uninstallation, contain files which were not put
>>> there during installation of the distribution being removed? It would be useful
>>> for packaging tools to inform users about the extraneous, unexpected files and
>>> perhaps get confirmation before proceeding with directory deletion.
>>
>> Are there scenarios where it is possible to have "expected" files that
>> are not created during installation but rather during the course of
>> running the application (e.g. preference files or cache files of some
>> sort)?  If so, for cleanup purposes, another option is to have a
>> provision for specifying such "post-installation" expected files.
>
> The obvious example is pyc/pyo files.
>
> It would be good to cater better for "clean" uninstalls. Would it not
> be easier though to simply record the directories that the installer
> created (probably just in RECORD, but maybe in a separate file) and
> once all the files have been deleted, delete the directories if they
> are empty or prompt if there are (presumably user-created) files left?
> I'd make an exception for pyc/pyo files and __pycache__ subdirectories
> and ignore them in that last "is the directory empty?" check.

The main problem I can see is with namespace packages: you could get a
"Do you want to delete this directory?" every time you uninstalled a
distribution that contributed files to a namespace package. A mistaken
"yes" could seriously mess up your Python instance. Having a given
distribution "own" the namespace package directory could solve that,
but PEP 420 was specifically designed so that namespace packages no
longer needed to have an owner in Python 3.3+.

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
a command wouldn't be able to safely clean cached bytecode files from
versions prior to Python 3.2 due to bytecode only distributions,
though. For that case, it will still be up to the installers to
correctly list the bytecode filenames, so the cleaner will be able to
detect the empty directory after the distribution is removed.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia


More information about the Distutils-SIG mailing list