1
votes

I am using python script to execute in custom action in wix project.

binary Id="python_script" SourceFile="myscript.py"

Custom action as:

CustomAction Id="CA_python_script" BinaryKey="python_script" Execute="immediate" Impersonate="yes" Return="check" ExeCommand=""[COMMANDPROMPT]" /c "C:\Python26\python.exe myscript.py""

I have also tried as:

CustomAction Id="CA_python_script" BinaryKey="python_script" Execute="immediate" Impersonate="yes" Return="check" ExeCommand=""[COMMANDPROMPT]" /c "C:\Python26\python.exe python_script""

failed with errors:

MSI (s) (40:14) [15:18:47:204]: Note: 1: 1721 2: CA_python_script 3: C:\Windows\Installer\MSI33F9.tmp 4: "C:\Windows\system32\cmd.exe" /c "C:\Python26\python.exe myscript.py" Error 1721. There is a problem with this Windows Installer package. A program required for this install to complete could not be run. Contact your support personnel or package vendor. Action: CA_python_script, location: C:\Windows\Installer\MSI33F9.tmp, command: "C:\Windows\system32\cmd.exe" /c "C:\Python26\python.exe myscript.py" MSI (s) (40:14) [15:18:51:782]: Product: MY software -- Error 1721. There is a problem with this Windows Installer package. A program required for this install to complete could not be run. Contact your support personnel or package vendor. Action: backup_Registry_Cmd, location: C:\Windows\Installer\MSI33F9.tmp, command: "C:\Windows\system32\cmd.exe" /c "C:\Python26\python.exe myscript.py"

Action ended 15:18:51: backup_Registry_Cmd. Return value 3.

what is the problem in this?

3

3 Answers

1
votes

I know I'm a rather late-comer in the thread, but I ran across it and figured I'd answer for anyone else that does.

The fundamental problem is that you cannot rely on the user:

  1. Having Python Installed
  2. Having the correct versopn of Python Installed
  3. The location of python if it is installed
  4. The correct packages/libs installed

You also can only run an executable from python. The simplest thing you can do is to compile your python script into an EXE.

Using tools like py2exe, pyInstaller, or best cx_Freeze you can "compile" your python script into a .EXE file which you can include & run from your WiX project.

The nice thing about this is that these tools will make sure your python script is executed agaist the correct python binary, and will bring along all the dependencies you need and embed them into the .EXE file.

Word of warning: These solutions aren't iron clad, they're very versitile but you may run into issues, so its possible this may not work for your purposes.

0
votes

Custom actions from the Binary table can be either DLLs or EXEs. There's no support to extract a file and pass it to another .exe.

0
votes

One reason for having problems like this is that there is a space somewhere in your command. WiX doesn't take too kindly to spaces.

Not to shamelessly promote an article I wrote on the exact subject on handling scripting languages when using WiX, but here it is: http://www.optimalbpm.se/wiki/index.php/Wix_and_scripting_languages

With regards to the problem other mentioned in other answers, the one of satisfying the other requirements mentioned here; I also wrote a guide on how to convert the exe installers from pythonlibs to .msi: http://www.optimalbpm.se/wiki/index.php/Python_packages_from_exe_to_WiX_to_msi

The reason for that is to install otherwise uninstallable python packages(some they require Visual studio to compile in pip). For example, lxml doesn't work without binary installation.