commit 8a394c22eb8a2bbd506163db3be7c951e11aa579 Author: eszense Date: Thu Jan 19 21:04:54 2017 +0800 Combined fix for Issue 15797 and 29313 diff --git a/Lib/distutils/command/bdist_msi.py b/Lib/distutils/command/bdist_msi.py index 33d52ff..9102e4f 100644 --- a/Lib/distutils/command/bdist_msi.py +++ b/Lib/distutils/command/bdist_msi.py @@ -376,15 +376,33 @@ class bdist_msi(Command): def add_scripts(self): if self.install_script: + #install start = 6800 for ver in self.versions + [self.other_version]: install_action = "install_script." + ver exe_prop = "PYTHON" + ver add_data(self.db, "CustomAction", - [(install_action, 50, exe_prop, '"' + self.install_script_key + '"')]) + [(install_action, 50, exe_prop, '"%s" -install' % self.install_script_key)]) add_data(self.db, "InstallExecuteSequence", [(install_action, "&Python%s=3" % ver, start)]) start += 1 + + # uninstall: + # http://msdn.microsoft.com/en-us/library/windows/desktop/aa368013%28v=vs.85%29.aspx + # "If the action is sequenced after the InstallValidate action in the + # InstallExecuteSequence table, the package author may specify a condition + # of REMOVE="ALL" for the action in the Condition column + start = 1401 + for ver in self.versions + [self.other_version]: + uninstall_action = "uninstall_script." + ver + exe_prop = "PYTHON" + ver + add_data(self.db, "CustomAction", + [(uninstall_action, 50, exe_prop, '"%s" -uninstall' % self.install_script_key)]) + add_data(self.db, "InstallExecuteSequence", + [(uninstall_action, "!Python%s=3" % ver, start)]) + start += 1 + + # XXX pre-install scripts are currently refused in finalize_options() # but if this feature is completed, it will also need to add # entries for each version as the above code does