[Distutils] problem with bdist_msi post-install script

Bill Janssen janssen at parc.com
Mon Mar 22 16:19:22 CET 2010

Martin, here's another question.  The ability to add pre-install scripts
seems to be implemented:

        if self.pre_install_script:
            scriptfn = os.path.join(self.bdist_dir, "preinstall.bat")
            f = open(scriptfn, "w")
            # The batch file will be executed with [PYTHON], so that %1
            # is the path to the Python interpreter; %0 will be the path
            # of the batch file.
            # rem ="""
            # %1 %0
            # exit
            # """
            # <actual script>
            f.write('rem ="""\n%1 %0\nexit\n"""\n')
            add_data(self.db, "Binary",
                [("PreInstall", msilib.Binary(scriptfn))
            add_data(self.db, "CustomAction",
                [("PreInstall", 2, "PreInstall", None)
            add_data(self.db, "InstallExecuteSequence",
                    [("PreInstall", "NOT Installed", 450)])

But this doesn't look quite complete.  I don't see where the Python
interpreter is actually invoked here.  (Cute trick swapping the args,
by the way).

Which is presumably why, in finalize_options, we find:

        if self.pre_install_script:
            raise DistutilsOptionError, "the pre-install-script feature is not yet implemented"

Shouldn't the custom action be this:

            add_data(self.db, "CustomAction",
                [("PreInstall", 2, "PreInstall", '"PYTHON"'),


More information about the Distutils-SIG mailing list