Issue 12416: packaging needs {pre,post}-{install,remove} hooks (original) (raw)

Created on 2011-06-26 23:50 by vinay.sajip, last changed 2022-04-11 14:57 by admin. 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
2022-04-11 14:57:19 admin set github: 56625
2014-03-13 03:32:30 eric.araujo set status: open -> closednosy: + ncoghlanresolution: out of datestage: resolved
2011-10-19 20:07:22 eric.araujo set assignee: tarek -> eric.araujomessages: +
2011-10-06 15:26:51 eric.araujo set title: packaging does not have hooks callable during distribution removal -> packaging needs {pre,post}-{install,remove} hooksmessages: + versions: + 3rd party
2011-06-27 15:34:40 eric.araujo set messages: +
2011-06-27 15:21:41 tarek set messages: +
2011-06-27 15:16:05 eric.araujo set messages: +
2011-06-27 15:14:19 tarek set messages: +
2011-06-27 14:06:13 eric.araujo set messages: +
2011-06-26 23:50:46 vinay.sajip create