classification
Title: packaging needs {pre,post}-{install,remove} hooks
Type: enhancement Stage: resolved
Components: Distutils2, Library (Lib) Versions: Python 3.3, 3rd party
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: eric.araujo Nosy List: alexis, eric.araujo, ncoghlan, tarek, vinay.sajip
Priority: normal Keywords:

Created on 2011-06-26 23:50 by vinay.sajip, last changed 2014-03-13 03:32 by eric.araujo. This issue is now closed.

Messages (8)
msg139230 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2011-06-26 23:50
In general it is possible for an installation to make certain system changes other than the record of files written during an installation (for example, under Windows, there may be distribution-specific Windows registry updates).

There seems to be no hook that's called when a distribution is removed, which would allow distribution-specific cleanup code to be called (e.g. to undo Windows registry changes).

Such a hook should be provided.
msg139274 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-06-27 14:06
I have no objection, but you may want to ask on the fellowship ML first.

Should the hooks be run before the removal or just after?  (Debian for example has both, which makes four hooks: preinst, postinst, prerm, postrm).  Our setup_hooks (used with pysetup commands) are run right after the setup.cfg file is parsed, before any operation is started.

Regarding implementation: The hook should be defined in the global section of setup.cfg; upon installation, packaging would write this info into the dist-info directory (say in an UNINSTALLHOOKS file), which would be read when preparing an uninstallation.
msg139295 - (view) Author: Tarek Ziadé (tarek) * (Python committer) Date: 2011-06-27 15:14
Sounds good. Also, we should make the assumption that this hook might be deactivated or might fail. So it should not break the uninstallation in this case (a warning seem fine)
msg139296 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-06-27 15:16
Definitely, hooks do not stop operation.  I’ll double-check that.  We may want an option to turn hooks failures into fatal errors.
msg139298 - (view) Author: Tarek Ziadé (tarek) * (Python committer) Date: 2011-06-27 15:21
We need to make it crystal clear in the doc: developers need to understand this behavior.

Also, for a fatal error, I am -1 for activating this for an uninstall hook because we want to uninstall wathever happens in the hooks, +1 for others (as long as it's coupled with a --force option)

It can be a specific exception the hook can raise to stop the process
msg139302 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-06-27 15:34
The setup.cfg spec says only this:

> The callables are executed in the order they’re found in the file; if
> one of them cannot be found, tools should not stop, but for example
> produce a warning and continue with the next line.

packaging/commandhooks does not say anything.  I’ll open a bug to add docs and tests about that, and a feature request for the new option to turn warnings into fatal errors.
msg145019 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-10-06 15:26
Editing title to reflect the scope of the needed feature.
msg145952 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-10-19 20:07
I’ve opened #13225 about the error handling.
History
Date User Action Args
2014-03-13 03:32:30eric.araujosetstatus: open -> closed
nosy: + ncoghlan

resolution: out of date
stage: resolved
2011-10-19 20:07:22eric.araujosetassignee: tarek -> eric.araujo
messages: + msg145952
2011-10-06 15:26:51eric.araujosettitle: packaging does not have hooks callable during distribution removal -> packaging needs {pre,post}-{install,remove} hooks
messages: + msg145019
versions: + 3rd party
2011-06-27 15:34:40eric.araujosetmessages: + msg139302
2011-06-27 15:21:41tareksetmessages: + msg139298
2011-06-27 15:16:05eric.araujosetmessages: + msg139296
2011-06-27 15:14:19tareksetmessages: + msg139295
2011-06-27 14:06:13eric.araujosetmessages: + msg139274
2011-06-26 23:50:46vinay.sajipcreate