--- bdist_msi.py 2012-08-28 10:24:11.839464900 +0100 +++ bdist_msi-fixed.py 2012-08-28 10:34:37.581138400 +0100 @@ -174,6 +174,7 @@ "install_script '%s' not found in scripts" % \ self.install_script self.install_script_key = None + self.uninstall_script_key = None # finalize_options() @@ -314,7 +315,8 @@ if self.install_script_key: raise DistutilsOptionError( "Multiple files with name %s" % file) - self.install_script_key = '[#%s]' % key + self.install_script_key = '[#%s] -install' % key + self.uninstall_script_key = '[#%s] -remove' % key else: key = seen[afile] add_data(self.db, "DuplicateFile", @@ -378,15 +380,34 @@ 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)]) 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, self.uninstall_script_key)]) + add_data(self.db, "InstallExecuteSequence", + [(uninstall_action, '!Python%s=3 And REMOVE="ALL"' % 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